From a8135e8c85c985764cd96b0b6f7b3028a0cf2def Mon Sep 17 00:00:00 2001 From: Raymond Hackley Date: Tue, 7 Mar 2023 10:41:06 +0000 Subject: [PATCH] OpenRC-Script.md: initialize kuma.db - Initialize `kuma.db` if missing, and fix `$directory/data/kuma.db\*` created during `start_pre()` at first run - Merge log files, and fix `$log_dir/*.log` created during `start_pre()` at first run - Fix typo --- OpenRC-Script.md | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/OpenRC-Script.md b/OpenRC-Script.md index 8874c83..0465960 100644 --- a/OpenRC-Script.md +++ b/OpenRC-Script.md @@ -11,8 +11,9 @@ directory=${directory:-/usr/share/uptime-kuma} pidfile=${pidfile:-/run/$RC_SVCNAME.pid} log_dir="/var/log/$RC_SVCNAME" -output_log="${output_log:-$log_dir/output.log}" -error_log="${error_log:-$log_dir/error.log}" +logfile=${logfile:-$log_dir/$RC_SVCNAME.log} +output_log="${output_log:-$logfile}" +error_log="${error_log:-$logfile}" command=${command:-/usr/bin/node} command_args="$directory/server/server.js" @@ -27,9 +28,12 @@ start_pre() { checkpath --owner=$command_user --directory $log_dir \ $directory/data \ $directory/data/upload - checkpath --owner=$command_user --file $log_dir/*.log \ + checkpath --owner=$command_user --file $logfile \ $directory/data/error.log + [ ! -e $directory/data/kuma.db ] && + cp $directory/db/kuma.db $directory/data/ + checkpath --owner=$command_user --mode 600 --file $directory/data/kuma.db* } @@ -52,14 +56,7 @@ sudo addgroup -S uptime-kuma sudo adduser -S -D -h /var/lib/uptime-kuma -s /sbin/nologin -G uptime-kuma -g uptime-kuma uptime-kuma ``` -If the database is not initialized, it has to be run fisrt. - -```sh -cd /usr/share/uptime-kuma -sudo -u uptime-kuma node server/server.js -``` - -Start the service and add it to default runlevel if prefered. +Start the service and add it to default runlevel if preferred. ```sh sudo rc-service uptime-kuma start