Add openrc filestoraged script.

master
Philippe Pittoli 2023-02-15 15:44:17 +01:00
parent 54cdb42301
commit 44a3f553bc
1 changed files with 66 additions and 0 deletions

66
openrc/filestoraged Executable file
View File

@ -0,0 +1,66 @@
#!/sbin/openrc-run
: ${cfgfile:="/etc/baguette/filestorage.yml"}
: ${auth_password_file:="/etc/baguette/auth-password"}
command_user="_filestorage:_ipc"
# The command cannot go background by itself and cannot write its own PID.
command_background=true
description="File Storage daemon"
description_checkconfig="Verify configuration file (TODO)"
description_reload="Reload configuration (TODO)"
description_debug="Print actual command line to run"
extra_commands="checkconfig debug"
extra_started_commands="reload"
pidfile="${FILESTORAGED_PIDFILE:-"/run/$RC_SVCNAME.pid"}"
command="${FILESTORAGED_BINARY:-"/usr/local/bin/filestoraged"}"
command_args="${command_args:-${FILESTORAGED_OPTS:- -k $auth_password_file}}"
depend() {
need auth
}
required_files="$cfgfile $auth_password_file"
debug() {
ewarn Hello this is debug.
ewarn auth_password_file: $auth_password_file
ewarn pidfile: $pidfile
ewarn command: $command
ewarn command_args: $command_args
}
checkconfig() {
if [ ! -d /run/ipc ] ; then
mkdir -p /run/ipc || return 1
fi
# "$command" -t $command_args || return 1
ewarn "filestoraged cannot check its own configuration files, yet"
return 0
}
start_pre() {
checkconfig
}
stop_pre() {
if [ "${RC_CMD}" = "restart" ] ; then
checkconfig || return 1
fi
}
reload() {
ewarn "Reloading: not available, let's just restart."
# checkconfig || return 1
restart || return 1
# ebegin "Reloading $RC_SVCNAME"
# start-stop-daemon --signal HUP \
# --exec "$command" --pidfile "$pidfile"
# eend $?
}