diff --git a/lib/SetupWizard.php b/lib/SetupWizard.php index 8d7c150..f0dbf88 100644 --- a/lib/SetupWizard.php +++ b/lib/SetupWizard.php @@ -91,6 +91,26 @@ public function hasSystemd(): bool { return $result === 0; } + public function hasRcd(): bool { + $result_bin = null; + $result_dir = null; + $output_bin = []; + $output_dir = []; + // Check if /usr/sbin/service is executable + exec('/bin/sh -c "test -x /usr/sbin/service"', $output_bin, $result_bin); + if ($result_bin !== 0) { + return false; + } + // Check for /usr/local/etc/rc.d + exec('test -d /usr/local/etc/rc.d', $output_dir, $result_dir); + if ($result_dir === 0) { + return true; + } + // Check for /etc/rc.d (always exists on FreeBSD) + exec('test -d /etc/rc.d', $output_dir, $result_dir); + return $result_dir === 0; + } + public function hasSELinux(): bool { $result = null; $output = []; diff --git a/service_scripts/nextcloud_notify_push b/service_scripts/nextcloud_notify_push index 0b8bff6..b69ee3b 100644 --- a/service_scripts/nextcloud_notify_push +++ b/service_scripts/nextcloud_notify_push @@ -1,36 +1,48 @@ -#! /bin/sh +#!/bin/sh # -# $FreeBSD$ -# - # PROVIDE: nextcloud_notify_push # REQUIRE: NETWORKING DAEMON # KEYWORD: shutdown # -# Add the following lines to /etc/rc.conf to enable nextcloud_notify_push: -# -#nextcloud_notify_push_enable="YES" -#nextcloud_notify_push_droot="YOUR NEXTCLOUD DIRECTORY ROOT" +# Add the following line to /etc/rc.conf to enable nextcloud_notify_push: +# nextcloud_notify_push_enable="YES" . /etc/rc.subr name="nextcloud_notify_push" -rcvar="nextcloud_notify_push_enable" +rcvar="${name}_enable" load_rc_config $name +: ${nextcloud_notify_push_enable:="NO"} +: ${nextcloud_notify_push_user:="www"} +: ${nextcloud_notify_push_group:="www"} : ${nextcloud_notify_push_enable:=NO} -: ${nextcloud_notify_push_droot:=/usr/local/www/html} +: ${nextcloud_notify_push_droot:=/usr/local/www/nextcloud} : ${nextcloud_notify_push_config:=${nextcloud_notify_push_droot}/config/config.php} -: ${nextcloud_notify_push_flags:=-p 7867} -my_flags=${nextcloud_notify_push_flags} -nextcloud_notify_push_flags= +pushserver_flags="-p 7867" -pidfile=/var/run/nextcloud_notify_push.pid +pidfile="/var/run/${name}.pid" binary="${nextcloud_notify_push_droot}/apps/notify_push/bin/fbsd_amd64/notify_push" + command="/usr/sbin/daemon" -command_args="-S -u www -P ${pidfile} -- ${binary} ${my_flags} ${nextcloud_notify_push_config}" +command_args="-S -r -P ${pidfile} -- ${binary} ${pushserver_flags} ${nextcloud_notify_push_config}" + +start_precmd="${name}_precmd" +stop_postcmd="${name}_postcmd" + +nextcloud_notify_push_precmd() +{ + # Create pidfile for user:group + install -o ${nextcloud_notify_push_user} -g ${nextcloud_notify_push_group} /dev/null ${pidfile} +} + +nextcloud_notify_push_postcmd() +{ + # Clean up + rm -f ${pidfile} +} run_rc_command "$1"