From f1b7313fde3cc13098fe19f0240e980484f63f8f Mon Sep 17 00:00:00 2001 From: Raymond Hackley Date: Fri, 19 Aug 2022 12:13:51 +0000 Subject: [PATCH] README.rst: Update OpenRC script Use variables, depend on revelant services and add start_pre() to check paths automatically. Signed-off-by: Raymond Hackley --- README.rst | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 59789b7..c2479a8 100644 --- a/README.rst +++ b/README.rst @@ -267,20 +267,31 @@ On Alpine/postmarketOS/Gentoo/Artix or the other OpenRC based distros, you can c description="Nextcloud News Updater Daemon" - pidfile=${pidfile:-/run/nextcloud-news-updater.pid} - output_log="/var/log/nextcloud-news-updater/output.log" - error_log="/var/log/nextcloud-news-updater/error.log" + log_directory="/var/log/$RC_SVCNAME" + pidfile=${pidfile:-/run/$RC_SVCNAME.pid} + output_log="${output_log:-$log_directory/output.log}" + error_log="${error_log:-$log_directory/error.log}" + config_file="/etc/$RC_SVCNAME/updater.ini" command=${command:-/usr/bin/nextcloud-news-updater} command_user=${command_user:-www-data:www-data} - command_args="-c /etc/nextcloud/news/updater.ini" + command_args="-c $config_file" command_background=true + depend() { + need net + use mariadb postgresql + } + + start_pre() { + checkpath --directory --owner $command_user "$log_directory" + checkpath --file --owner $command_user "$output_log" "$error_log" + checkpath --directory "/etc/$RC_SVCNAME" + checkpath --file --mode 0600 --owner $command_user "$config_file" + } + Then to enable and start it run:: - sudo -u www-data mkdir /var/log/nextcloud-news-updater - sudo -u www-data touch /var/log/nextcloud-news-updater/output.log \ - /var/log/nextcloud-news-updater/error.log sudo chmod 755 /etc/init.d/nextcloud-news-updater sudo rc-update add nextcloud-news-updater sudo rc-service nextcloud-news-updater start