aboutsummaryrefslogtreecommitdiffstats
path: root/config/phpservice
diff options
context:
space:
mode:
authorChris Buechler <cmb@pfsense.org>2015-11-16 01:45:10 -0600
committerChris Buechler <cmb@pfsense.org>2015-11-16 01:45:10 -0600
commitf51290a48ef02bd2831c57d4cec6ea2b7d6dd97e (patch)
tree6a43ef271862f501873f525048f95b6ac770e50f /config/phpservice
parent89572c6d988823d5869feec700295c930d14fdbe (diff)
parente64e2a87b0952800298bf9c22ebb3463db70d505 (diff)
downloadpfsense-packages-f51290a48ef02bd2831c57d4cec6ea2b7d6dd97e.tar.gz
pfsense-packages-f51290a48ef02bd2831c57d4cec6ea2b7d6dd97e.tar.bz2
pfsense-packages-f51290a48ef02bd2831c57d4cec6ea2b7d6dd97e.zip
Merge pull request #1173 from doktornotor/patch-5
Diffstat (limited to 'config/phpservice')
-rw-r--r--config/phpservice/phpservice.inc40
-rw-r--r--config/phpservice/phpservice.priv.inc38
-rw-r--r--config/phpservice/phpservice.xml20
3 files changed, 77 insertions, 21 deletions
diff --git a/config/phpservice/phpservice.inc b/config/phpservice/phpservice.inc
index d04e021a..8ccd4f3c 100644
--- a/config/phpservice/phpservice.inc
+++ b/config/phpservice/phpservice.inc
@@ -27,12 +27,13 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
+require_once('pkg-utils.inc');
+
function phpservice_sync_package() {
global $config;
-
+ conf_mount_rw();
+
if ($config['installedpackages']['phpservice']['config'] != "") {
-
- conf_mount_rw();
$tmp = <<<EOF
<?php
@@ -47,10 +48,10 @@ fclose($fp);
unset($filename);
function send_to_syslog($syslogaddress, $syslogport, $syslogmsg) {
-
+
$syslogaddress = "127.0.0.1";
$syslogport = 514;
-
+
$fp = fsockopen("udp://".$syslogaddress, $syslogport, $errno, $errstr);
if (!$fp) {
return;
@@ -75,8 +76,8 @@ EOF;
$tmp_php = base64_decode($rowhelper['php']);
if (strlen($tmp_php) > 0) {
$tmp .= "// name: ".$rowhelper['name']." \n";
- $tmp .= "// description: ".$rowhelper['description']." \n\n";
- $tmp .= base64_decode($rowhelper['php']);
+ $tmp .= "// description: " . $rowhelper['description'] . " \n\n";
+ $tmp .= preg_replace('/\r\n/', "\n", base64_decode($rowhelper['php']));
$tmp .= "\n";
}
}
@@ -96,21 +97,36 @@ EOF;
unset($tmp);
fclose($fout);
- restart_service("phpservice");
- conf_mount_ro();
+ phpservice_write_rcfile();
+ if (is_service_running("phpservice")) {
+ restart_service("phpservice");
+ } else {
+ start_service("phpservice");
+ }
} else {
stop_service("phpservice");
+ unlink_if_exists("/usr/local/etc/rc.d/phpservice.sh");
}
+ conf_mount_ro();
}
-function phpservice_install_command() {
+function phpservice_write_rcfile() {
write_rcfile(array(
"file" => "phpservice.sh",
- "start" => "/usr/local/bin/php /usr/local/pkg/phpservice.php >> /var/log/phpservice.log &",
+ "start" => "/usr/local/bin/php -f /usr/local/pkg/phpservice.php >> /var/log/phpservice.log &",
"stop" => "/bin/rm -f /tmp/phpmonitor.pid; sleep 3"
)
);
- phpservice_sync_package();
+}
+
+function phpservice_custom_php_service_status_command() {
+ exec("/bin/pgrep -fq phpservice", $output, $retval);
+ return $retval;
+}
+
+function phpservice_deinstall_command() {
+ rmdir_recursive("/usr/local/www/packages/phpservice");
+ unlink_if_exists("/usr/local/pkg/phpservice.php");
}
?>
diff --git a/config/phpservice/phpservice.priv.inc b/config/phpservice/phpservice.priv.inc
new file mode 100644
index 00000000..ec10c77e
--- /dev/null
+++ b/config/phpservice/phpservice.priv.inc
@@ -0,0 +1,38 @@
+<?php
+/*
+ phpservice.priv.inc
+ part of pfSense (http://www.pfSense.org/)
+ 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:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+global $priv_list;
+
+$priv_list['page-services-phpservice'] = array();
+$priv_list['page-services-phpservice']['name'] = "WebCfg - Services: PHPService package";
+$priv_list['page-services-phpservice']['descr'] = "Allow access to PHPService package GUI";
+$priv_list['page-services-phpservice']['match'] = array();
+$priv_list['page-services-phpservice']['match'][] = "packages/phpservice/phpservice_php.php*";
+$priv_list['page-services-phpservice']['match'][] = "packages/phpservice/phpservice_php_edit.php*";
+
+?>
diff --git a/config/phpservice/phpservice.xml b/config/phpservice/phpservice.xml
index 6bada596..f55dfe23 100644
--- a/config/phpservice/phpservice.xml
+++ b/config/phpservice/phpservice.xml
@@ -41,14 +41,12 @@
/* ====================================================================================== */
]]>
</copyright>
- <description>PHP Service</description>
- <name>PHP Service Settings</name>
- <version>0.5.0</version>
- <title>Settings</title>
+ <name>phpservice</name>
+ <version>0.5.2</version>
+ <title>PHPService</title>
<include_file>/usr/local/pkg/phpservice.inc</include_file>
<menu>
<name>PHPService</name>
- <tooltiptext>PHP Service settings.</tooltiptext>
<section>Services</section>
<configfile>phpservice.xml</configfile>
<url>/packages/phpservice/phpservice_php.php</url>
@@ -59,7 +57,7 @@
<executable>phpservice</executable>
<description>PHP script as a service</description>
<custom_php_service_status_command>
- exec("/bin/pgrep -fq phpservice");
+ phpservice_custom_php_service_status_command();
</custom_php_service_status_command>
</service>
<configpath>installedpackages->package->$packagename->configuration->phpservice</configpath>
@@ -68,6 +66,10 @@
<item>https://packages.pfsense.org/packages/config/phpservice/phpservice.inc</item>
</additional_files_needed>
<additional_files_needed>
+ <prefix>/etc/inc/priv/</prefix>
+ <item>https://packages.pfsense.org/packages/config/phpservice/phpservice.priv.inc</item>
+ </additional_files_needed>
+ <additional_files_needed>
<prefix>/usr/local/www/packages/phpservice/</prefix>
<item>https://packages.pfsense.org/packages/config/phpservice/phpservice_php.php</item>
</additional_files_needed>
@@ -78,7 +80,7 @@
<custom_php_resync_config_command>
phpservice_sync_package();
</custom_php_resync_config_command>
- <custom_php_install_command>
- phpservice_install_command();
- </custom_php_install_command>
+ <custom_php_deinstall_command>
+ phpservice_deinstall_command();
+ </custom_php_deinstall_command>
</packagegui>