From cff43c6b7289877c95c4dbbbd2285248b19f919f Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 16 Nov 2015 01:36:54 +0100 Subject: (de)install and service handling fixes --- config/phpservice/phpservice.inc | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'config/phpservice') 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 = << 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"); } ?> -- cgit v1.2.3