aports/testing/keydb/keydb.initd
2024-05-25 20:52:39 +00:00

46 lines
1 KiB
Bash

#!/sbin/openrc-run
name="KeyDB server"
description="High performance multithreaded fork of Redis"
: ${cfgfile:="/etc/keydb/keydb.conf"}
: ${command_user:="keydb:keydb"}
command="/usr/bin/keydb-server"
command_args="$cfgfile --daemonize no $command_args"
command_background="yes"
pidfile="/run/$RC_SVCNAME.pid"
required_files="$cfgfile"
depend() {
use net localmount logger
after keepalived firewall
provide redis
}
start_pre() {
# Sets start-start-daemon's --chdir.
directory="$(config_get 'dir' '/var/lib/keydb')"
checkpath -d -o "$command_user" "$directory" || return 1
local logfile="$(config_get 'logfile')"
if [ "$logfile" ]; then
checkpath -f -o "$command_user" "$logfile" || return 1
fi
local unixsocket="$(config_get 'unixsocket')"
if [ "$unixsocket" ] && ! [ -e "${unixsocket%/*}" ]; then
checkpath -d -o "$command_user" "${unixsocket%/*}" || return 1
fi
return 0
}
config_get() {
local key="$1"
local default="${2:-}"
local value="$(awk "\$1 == \"$key\" { print \$2 }" "$cfgfile")"
printf '%s\n' "${value:-$default}"
}