⌈⌋ branch:  freshcode


Check-in [2b7b9307c4]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:2b7b9307c432706a4242066037746f507bde1178
Date: 2014-11-22 21:29:22
User: mario
Comment:Automated cronjob re-registration from `x-cron:` plugin meta fields.
Tags And Properties
  • branch=trunk inherited from [82405bb421]
  • sym-trunk inherited from [82405bb421]
Context
2014-11-22
21:29
[e86d921713] Rename QPL to QtPL (user: mario, tags: trunk)
21:29
[2b7b9307c4] Automated cronjob re-registration from `x-cron:` plugin meta fields. (user: mario, tags: trunk)
21:28
[d9a13a9d82] Switch to raw `twurl` requests for Twitter updates, as that allows to embed screenshots easily. (user: mario, tags: trunk)
Changes

Added cron.daily/_cronjobs.php.





















































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
#
# title: cronjob collector
# description: parses out cron: specifiers from plugins and installs crontab
# version: 0.1
# cron: 0 0 * * *
# type: cron
# 
# Reregisters cronjobs from current dir (cron.daily/) into crontab
# according to x-cron: specifiers.


// keep previous crontab entries not pointing to current __DIR__
$dir = preg_quote(__DIR__, "~");
$CRONTAB = preg_replace(
    "~((?<=\n)\R+)?(^#.+\R+)*^.*$dir.*\R~m",
    "",
    `crontab -l`
);


// traverse all files in cron.d/
foreach (glob(__DIR__."/*.*") as $fn) {

    // coarse plugin meta data extraction
    preg_match_all("~ ^ [#/*\h]+ (?:x-)? (cron|title|description|version|type): \h* (\V+)  ~mix", file_get_contents($fn), $m);
    $m = array_change_key_case(array_combine($m[1], $m[2] ));

    // assert existing `cron:` specifier
    if (!empty($m["cron"]) and preg_match("~^([*/\d-]+(\h+|$)){5}$|^@(daily|hourly|midnight)$~", $m["cron"] = stripcslashes($m["cron"]))) {
       $CRONTAB .= "\n"
                .  "#-- $m[title]\n#   ($m[description])\n"
                .  "$m[cron] "
                .  "nice "
                .  pathinfo($fn, PATHINFO_EXTENSION)
                .  " $fn\n";
    }
    
}

// install new crontab
fwrite(popen("crontab", "w"), $CRONTAB);