mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-08-07 22:37:12 +02:00
56 lines
1.2 KiB
Plaintext
56 lines
1.2 KiB
Plaintext
#!/sbin/openrc-run
|
|
|
|
instance_name="${SVCNAME#*.}"
|
|
instance_name="${instance_name:-stunnel}"
|
|
config_file="${STUNNEL_CONFIGFILE:-/etc/stunnel/$instance_name.conf}"
|
|
|
|
extra_started_commands="reload"
|
|
|
|
command="/usr/bin/stunnel"
|
|
command_args="$config_file $STUNNEL_OPTIONS"
|
|
pidfile="/run/stunnel/$instance_name.pid" # default value
|
|
|
|
required_files="$config_file"
|
|
|
|
|
|
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 $SVCNAME"
|
|
start-stop-daemon --signal HUP --pidfile "$pidfile" --name stunnel
|
|
eend $?
|
|
}
|
|
|
|
config_get() {
|
|
local key="$1"
|
|
local default="${2:-}"
|
|
|
|
local val="$(sed -En "s|^$key\s*=\s*(.*)\s*$|\1|p" "$config_file")"
|
|
echo "${val:-$default}"
|
|
}
|