aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo G. Baio (dbaio) <dbaio@bsd.com.br>2014-01-26 13:33:00 -0200
committerDanilo G. Baio (dbaio) <dbaio@bsd.com.br>2014-01-26 13:33:00 -0200
commit4f0d3bd5e09fb8ff371a6b56830b155adc48fed1 (patch)
tree25b66d575f36eb94d47dbee6c7d6340bee4376fd
parent6e4487e155682494cf72e59cf8423f60c05a35c0 (diff)
downloadpfsense-packages-4f0d3bd5e09fb8ff371a6b56830b155adc48fed1.tar.gz
pfsense-packages-4f0d3bd5e09fb8ff371a6b56830b155adc48fed1.tar.bz2
pfsense-packages-4f0d3bd5e09fb8ff371a6b56830b155adc48fed1.zip
apcupsd - modifying default scripts to send mail reports on install package process
-rw-r--r--config/apcupsd/apcupsd.inc33
-rw-r--r--config/apcupsd/apcupsd.xml7
2 files changed, 38 insertions, 2 deletions
diff --git a/config/apcupsd/apcupsd.inc b/config/apcupsd/apcupsd.inc
index 9abc23ba..08ddd17e 100644
--- a/config/apcupsd/apcupsd.inc
+++ b/config/apcupsd/apcupsd.inc
@@ -39,6 +39,7 @@ require_once("globals.inc");
function php_install_apcupsd(){
sync_package_apcupsd();
+ apccontrol_scripts_install();
}
function php_deinstall_apcupsd(){
@@ -185,7 +186,37 @@ function sync_package_apcupsd(){
unlink($apcupsd_rcfile);
}
}
-
+
conf_mount_ro();
}
+
+function apccontrol_scripts_install(){
+
+ // check pfsense version
+ $pfs_version = substr(trim(file_get_contents("/etc/version")),0,3);
+ if ($pfs_version > 2.0){
+ define('APCUPSD_BASE', '/usr/pbi/apcupsd-' . php_uname("m"));
+ }
+ else {
+ define('APCUPSD_BASE', '/usr/local');
+ }
+
+ $apccontrol_scripts = array("offbattery","onbattery","commfailure","commok","changeme");
+ foreach($apccontrol_scripts as $apccontrol_script) {
+
+ $apccontrol_script_file=<<<EOF
+#!/bin/sh
+
+/usr/local/bin/php -f /usr/local/pkg/apcupsd_mail.php {$apccontrol_script} > /dev/null
+
+exit 0
+
+EOF;
+
+ file_put_contents(APCUPSD_BASE . "/etc/apcupsd/" . $apccontrol_script, $apccontrol_script_file, LOCK_EX);
+ }
+
+}
+
?>
+
diff --git a/config/apcupsd/apcupsd.xml b/config/apcupsd/apcupsd.xml
index 8674af61..ecd979f6 100644
--- a/config/apcupsd/apcupsd.xml
+++ b/config/apcupsd/apcupsd.xml
@@ -60,6 +60,11 @@
<prefix>/usr/local/pkg/</prefix>
<chmod>0755</chmod>
</additional_files_needed>
+ <additional_files_needed>
+ <item>http://www.pfsense.org/packages/config/apcupsd/apcupsd_mail.php</item>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ </additional_files_needed>
<menu>
<name>Apcupsd</name>
<tooltiptext>Setup Apcupsd specific settings</tooltiptext>
@@ -322,7 +327,7 @@ UPSTYPE DEVICE Description <br>
</options>
</field>
</fields>
- <custom_php_install_command>sync_package_apcupsd();</custom_php_install_command>
+ <custom_php_install_command>php_install_apcupsd();</custom_php_install_command>
<custom_php_command_before_form></custom_php_command_before_form>
<custom_php_after_head_command></custom_php_after_head_command>
<custom_php_after_form_command></custom_php_after_form_command>