From a66e40f7abe78944a3564f3bbf7de7a73e9d6717 Mon Sep 17 00:00:00 2001 From: mcrane Date: Mon, 6 Apr 2009 14:53:21 -0600 Subject: New pfSense package to manage xml cron items --- config/cron/cron.inc | 135 ++++++++++++++++++++++ config/cron/cron.tmp | 195 ++++++++++++++++++++++++++++++++ config/cron/cron.xml | 121 ++++++++++++++++++++ config/cron/cron_edit.tmp | 281 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 732 insertions(+) create mode 100644 config/cron/cron.inc create mode 100644 config/cron/cron.tmp create mode 100644 config/cron/cron.xml create mode 100644 config/cron/cron_edit.tmp (limited to 'config/cron') diff --git a/config/cron/cron.inc b/config/cron/cron.inc new file mode 100644 index 00000000..5636111c --- /dev/null +++ b/config/cron/cron.inc @@ -0,0 +1,135 @@ +10^x|1024->2^x] + $s=array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'); + $e=floor(log($bytes,$convention)); + return round($bytes/pow($convention,$e),2).' '.$s[$e]; +} + + + +function php_sync_package() +{ + + global $config; + //synch cron tab + configure_cron(); + +} + + +function php_install_command() +{ + + global $config; + conf_mount_rw(); + config_lock(); + + if (!is_dir('/usr/local/www/packages/')) { + exec("mkdir /usr/local/www/packages/"); + } + + if (!is_dir('/usr/local/www/packages/cron/')) { + exec("mkdir /usr/local/www/packages/cron/"); + } + + + //rename PHP files from .tmp to .php + exec("cp /tmp/cron.tmp /usr/local/www/packages/cron/cron.php"); + unlink_if_exists("/tmp/cron.tmp"); + + exec("cp /tmp/cron_edit.tmp /usr/local/www/packages/cron/cron_edit.php"); + unlink_if_exists("/tmp/cron_edit.tmp"); + + //write_config(); + + //write_rcfile(array( + // "file" => "cron.sh", + // "start" => "/usr/local/bin/php /usr/local/pkg/cron.php >> /var/log/cron.log &", + // "stop" => "rm /tmp/cron.pid" + // ) + //); + + php_sync_package(); + //$handle = popen("/usr/local/etc/rc.d/cron.sh start", "r"); + //pclose($handle); + + //if (pkg_is_service_running('cron')) { + //documentation purposes + //} + + conf_mount_ro(); + config_unlock(); + +} + + +function deinstall_command() +{ + + conf_mount_rw(); + config_lock(); + $handle = popen("/usr/local/etc/rc.d/cron.sh stop", "r"); + unlink_if_exists("/usr/local/pkg/cron.xml"); + unlink_if_exists("/usr/local/www/cron.inc"); + exec("rm -R /usr/local/www/packages/cron"); + //unlink_if_exists("/usr/local/etc/rc.d/cron.sh"); + conf_mount_ro(); + config_unlock(); + +} + +?> \ No newline at end of file diff --git a/config/cron/cron.tmp b/config/cron/cron.tmp new file mode 100644 index 00000000..5eacd1c2 --- /dev/null +++ b/config/cron/cron.tmp @@ -0,0 +1,195 @@ + + + + + +

Cron:

+ +
+ + +
+ +
+ + + + + +
+ +
+"; +//print_info_box_np("This is an info box."); +//echo"
"; +//endif; + +?> + + + + +

+ Cron controls the scheduling of commands. +

+ For more information see: http://www.freebsd.org/doc/en/books/handbook/configtuning-cron.html +

+
+ + + + + + + + + + + + 0) { + + foreach ($a_cron as $ent) { + + ?> + + + + + + + + + + + + + + + + + + + +
MinuteHourWhoCommand + + + + + + +
+ +
+   + +   + +   + +   + + + + + + +
+
+ + + + + +
+
+ +
+ + +
+
+
+
+
+
+
+
+ +
+ +
+ + + + + diff --git a/config/cron/cron.xml b/config/cron/cron.xml new file mode 100644 index 00000000..15d7fd12 --- /dev/null +++ b/config/cron/cron.xml @@ -0,0 +1,121 @@ + + + + + + + + Cron + Describe your package requirements here + Currently there are no FAQ items provided. + Cron Settings + 0.1 + Settings + /usr/local/pkg/cron.inc + + cron + cron settings. +
Services
+ cron.xml + /packages/cron/cron.php +
+ + cron + cron.sh + cron + PHP run from a command line as a service. + + + + Settings + /pkg_edit.php?xml=cron.xml&id=0 + + + + Settings + /packages/cron.php + + + + installedpackages->package->$packagename->configuration->cron + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/cron/cron.xml + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/cron/cron.inc + + + /tmp/ + 0755 + http://www.pfsense.com/packages/config/cron/cron.tmp + + + /tmp/ + 0755 + http://www.pfsense.com/packages/config/cron/cron_edit.tmp + + + + Variable One + var1 + Enter the variable one here. + input + + + Variable Two + var1 + Enter the variable one here. + input + + + + + + php_sync_package(); + + + php_sync_package(); + + + php_install_command(); + + + deinstall_command(); + +
\ No newline at end of file diff --git a/config/cron/cron_edit.tmp b/config/cron/cron_edit.tmp new file mode 100644 index 00000000..9922e350 --- /dev/null +++ b/config/cron/cron_edit.tmp @@ -0,0 +1,281 @@ + + + + + + +

Cron: Edit

+ + + +
+ + +
+ +
+ + + + +
+ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ".htmlspecialchars($pconfig['php'])."\n"; + ?> + + + + + + + + +
minute + +
hour + +
mday + +
month + +
wday + +
who + +
command + +
  + + + + +
+
+ +
+
+
+
+
+
+ +
+ +
+ + + + -- cgit v1.2.3