From bba6d942c02cda13f76b962eeb4e623df0358be4 Mon Sep 17 00:00:00 2001 From: thstyl2000 <18458458+thstyl2000@users.noreply.github.com> Date: Thu, 27 Mar 2025 13:42:04 +0100 Subject: [PATCH 1/3] Added HasRcd function in SetupWizard.php Check is done by looking at directories. Signed-off-by: thstyl2000 <18458458+thstyl2000@users.noreply.github.com> --- lib/SetupWizard.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/SetupWizard.php b/lib/SetupWizard.php index 8d7c150..0cbe3d9 100644 --- a/lib/SetupWizard.php +++ b/lib/SetupWizard.php @@ -91,6 +91,23 @@ public function hasSystemd(): bool { return $result === 0; } + public function hasRcd(): bool { + $result = null; + $output = []; + // Check for /usr/local/etc/rc.d. Fallback to /etc/rc.d + exec('test -d /usr/local/etc/rc.d', $output, $result); + if ($result === 0) { + $output = '/usr/local/etc/rc.d'; + return true; + } else { + exec('test -d /etc/rc.d', $output, $result); + if ($result === 0) { + $output = '/etc/rc.d'; + return true; + } + } + } + public function hasSELinux(): bool { $result = null; $output = []; From af47c1fcebcd1da78c0b01f859d8f1221148a17a Mon Sep 17 00:00:00 2001 From: thstyl2000 <18458458+thstyl2000@users.noreply.github.com> Date: Thu, 27 Mar 2025 14:09:54 +0100 Subject: [PATCH 2/3] Updated SetupWizard.php Function hasRcd now also checks for 'service' command and fails if it not found. Signed-off-by: thstyl2000 <18458458+thstyl2000@users.noreply.github.com> --- lib/SetupWizard.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/SetupWizard.php b/lib/SetupWizard.php index 0cbe3d9..f0dbf88 100644 --- a/lib/SetupWizard.php +++ b/lib/SetupWizard.php @@ -92,20 +92,23 @@ public function hasSystemd(): bool { } public function hasRcd(): bool { - $result = null; - $output = []; - // Check for /usr/local/etc/rc.d. Fallback to /etc/rc.d - exec('test -d /usr/local/etc/rc.d', $output, $result); - if ($result === 0) { - $output = '/usr/local/etc/rc.d'; + $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; - } else { - exec('test -d /etc/rc.d', $output, $result); - if ($result === 0) { - $output = '/etc/rc.d'; - 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 { From 0b507a2b278ab40dc30c0f43173911444d98143a Mon Sep 17 00:00:00 2001 From: thstyl2000 <18458458+thstyl2000@users.noreply.github.com> Date: Mon, 19 May 2025 18:47:12 +0200 Subject: [PATCH 3/3] Update nextcloud_notify_push Signed-off-by: thstyl2000 <18458458+thstyl2000@users.noreply.github.com> --- service_scripts/nextcloud_notify_push | 42 +++++++++++++++++---------- 1 file changed, 27 insertions(+), 15 deletions(-) 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"