diff options
author | doktornotor <notordoktor@gmail.com> | 2015-08-12 12:02:24 +0200 |
---|---|---|
committer | doktornotor <notordoktor@gmail.com> | 2015-08-12 12:02:24 +0200 |
commit | fc15c06f6f8e135ac5ec2819702b9eb03882a747 (patch) | |
tree | 249ccc2119889c171d5ff364bf3c2376e160b4a5 /config/cron | |
parent | bf1a0bfdf47f7b52940d63cebf9d8032a0486703 (diff) | |
download | pfsense-packages-fc15c06f6f8e135ac5ec2819702b9eb03882a747.tar.gz pfsense-packages-fc15c06f6f8e135ac5ec2819702b9eb03882a747.tar.bz2 pfsense-packages-fc15c06f6f8e135ac5ec2819702b9eb03882a747.zip |
cron - rewrite broken package
- Remove cron service and other unused junk
- Clean up after previous broken versions
- Add a check for running cron after configure_cron() call. (TODO: Move this to pfSense core.)
Diffstat (limited to 'config/cron')
-rw-r--r-- | config/cron/cron.inc | 65 |
1 files changed, 11 insertions, 54 deletions
diff --git a/config/cron/cron.inc b/config/cron/cron.inc index a457cf58..7a7a8993 100644 --- a/config/cron/cron.inc +++ b/config/cron/cron.inc @@ -1,14 +1,11 @@ <?php -/* $Id$ */ -/* -/* ========================================================================== */ /* cron.inc + part of pfSense (https://www.pfSense.org/) Copyright (C) 2008 Mark J Crane + Copyright (C) 2015 ESF, LLC All rights reserved. - */ -/* ========================================================================== */ -/* + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -30,63 +27,23 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - require_once("services.inc"); -function cron_pkg_is_service_running($servicename) { - exec("/bin/ps ax | awk '{ print $5 }'", $psout); - array_shift($psout); - foreach ($psout as $line) { - $ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line))))); - } - if (is_service_running($servicename, $ps) or is_process_running($servicename)) { - return true; - } else { - return false; - } -} - function cron_sync_package() { - - global $config; - //synch cron tab configure_cron(); - exec("/usr/local/etc/rc.d/cron.sh stop"); - exec("/usr/local/etc/rc.d/cron.sh start"); - + // Previous package versions were "helpfully" killing cron on uninstall. + // Also, need to make sure cron is running, otherwise the package is useless. + // TODO: Something like this needs to be eventually done in configure_cron() in services.inc. + if (!is_process_running("cron")) { + exec("cd /tmp && /usr/sbin/cron -s 2>/dev/null"); + } } - function cron_install_command() { - - global $config; conf_mount_rw(); - - //write_config(); - - write_rcfile(array( - "file" => "cron.sh", - "start" => "[ `/bin/pgrep -f 'cron -s' | wc -l` -eq 0 ] && /usr/sbin/cron -s &", - "stop" => "[ -f \"/var/run/cron.pid\" ] && kill -9 `cat /var/run/cron.pid`; rm -f /var/run/cron.pid; /bin/pkill -f 'cron -s'" - ) - ); - - cron_sync_package(); - - //if (pkg_is_service_running('cron')) { - //documentation purposes - //} - - conf_mount_ro(); - -} - - -function cron_deinstall_command() { - conf_mount_rw(); - exec("/usr/local/etc/rc.d/cron.sh stop"); + // Clean up possible lingering garbage after previous package versions unlink_if_exists("/usr/local/etc/rc.d/cron.sh"); - conf_mount_ro(); + cron_sync_package(); } ?> |