projects/aports·blob master · refs

46 lines · 1.0 KiB

1#!/sbin/openrc-run
2
3name="KeyDB server"
4description="High performance multithreaded fork of Redis"
5
6: ${cfgfile:="/etc/keydb/keydb.conf"}
7: ${command_user:="keydb:keydb"}
8
9command="/usr/bin/keydb-server"
10command_args="$cfgfile --daemonize no $command_args"
11command_background="yes"
12pidfile="/run/$RC_SVCNAME.pid"
13
14required_files="$cfgfile"
15
16depend() {
17 use net localmount logger
18 after keepalived firewall
19 provide redis
20}
21
22start_pre() {
23 # Sets start-start-daemon's --chdir.
24 directory="$(config_get 'dir' '/var/lib/keydb')"
25 checkpath -d -o "$command_user" "$directory" || return 1
26
27 local logfile="$(config_get 'logfile')"
28 if [ "$logfile" ]; then
29 checkpath -f -o "$command_user" "$logfile" || return 1
30 fi
31
32 local unixsocket="$(config_get 'unixsocket')"
33 if [ "$unixsocket" ] && ! [ -e "${unixsocket%/*}" ]; then
34 checkpath -d -o "$command_user" "${unixsocket%/*}" || return 1
35 fi
36
37 return 0
38}
39
40config_get() {
41 local key="$1"
42 local default="${2:-}"
43
44 local value="$(awk "\$1 == \"$key\" { print \$2 }" "$cfgfile")"
45 printf '%s\n' "${value:-$default}"
46}