blob: a625d081c76360ea3503d442a40fccc47cef9769 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#!/sbin/openrc-run
extra_started_commands="reload reopen"
description_reload="Reload configuration file"
description_reopen="Reopen log file"
instance_name="${RC_SVCNAME#*.}"
instance_name="${instance_name:-stunnel}"
: ${cfgfile:=${STUNNEL_CONFIGFILE:-"/etc/stunnel/$instance_name.conf"}}
command="/usr/bin/stunnel"
command_args="$cfgfile $STUNNEL_OPTIONS $command_args"
pidfile="/run/stunnel/$instance_name.pid" # default value
required_files="$cfgfile"
depend() {
need net
before logger
}
start_pre() {
pidfile=$(config_get "pid" "$pidfile")
local chroot_dir=$(config_get "chroot")
[ -z "$chroot_dir" ] || start_stop_daemon_args="--chroot $chroot_dir"
local user=$(config_get "setuid" "stunnel")
local group=$(config_get "setgid" "stunnel")
checkpath -d -m 0775 -o root:$group /run/stunnel
if [ ! "$(dirname "$pidfile")" -ef "/run" ]; then
checkpath -d -m 0755 -o $user:$group "$(dirname "$pidfile")"
fi
}
stop_pre() {
pidfile=$(config_get "pid" "$pidfile")
}
reload() {
pidfile=$(config_get "pid" "$pidfile")
ebegin "Reloading $RC_SVCNAME configuration"
start-stop-daemon --signal HUP --pidfile "$pidfile" --name stunnel
eend $?
}
reopen() {
pidfile=$(config_get "pid" "$pidfile")
ebegin "Reopening $RC_SVCNAME log file"
start-stop-daemon --signal USR1 --pidfile "$pidfile" --name stunnel
eend $?
}
config_get() {
local key="$1"
local default="${2:-}"
local val="$(sed -En "s|^$key\s*=\s*(.*)\s*$|\1|p" "$cfgfile")"
echo "${val:-$default}"
}
|