Commit 663d500d authored by Jakub Jirutka's avatar Jakub Jirutka

community/stunnel: improve init script

parent 380daa93
......@@ -4,7 +4,7 @@
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=stunnel
pkgver=5.56
pkgrel=0
pkgrel=1
pkgdesc="SSL encryption wrapper between network client and server"
url="https://www.stunnel.org"
arch="all"
......@@ -49,5 +49,5 @@ package() {
}
sha512sums="db1be82b80bd5606568c5565f1c9a5710d4f7abca2d89388daa441bc395aaf2be998ac6403c7a17b8af01b89ade825186c20c50f73a809f9d64eca2e1b57a877 stunnel-5.56.tar.gz
33e215413e08fdd5783cc76e6ba6a2342fb6d0573f801815c4d3022625e71be6c9739d47a7a61bf7c803f27911b9c92cf6ae3e522add040f83802e1aaeaee000 stunnel.initd
51d56a6c0d961f6de5cd2ef07a1cfdb19fb1b74300da9c340899daa919bd9b2c0bfff472f03746df0dd1aa6098c79035921ca36108ca0b93693377f1ac1c7fb4 stunnel.initd
a72bfddeb74787d58c9fd24782d86c0498ce3530a43fbdd4ec4c4b57baa6257b6ef21005aca274b22c4a22cdbbbcee63dd3d841f458af248db9c69e8d59fa56f stunnel.conf"
#!/sbin/openrc-run
instance_name="${SVCNAME#*.}"
extra_started_commands="reload reopen"
description_reload="Reload configuration file"
description_reopen="Reopen log file"
instance_name="${RC_SVCNAME#*.}"
instance_name="${instance_name:-stunnel}"
config_file="${STUNNEL_CONFIGFILE:-/etc/stunnel/$instance_name.conf}"
extra_started_commands="reload"
: ${cfgfile:=${STUNNEL_CONFIGFILE:-"/etc/stunnel/$instance_name.conf"}}
command="/usr/bin/stunnel"
command_args="$config_file $STUNNEL_OPTIONS"
command_args="$cfgfile $STUNNEL_OPTIONS $command_args"
pidfile="/run/stunnel/$instance_name.pid" # default value
required_files="$config_file"
required_files="$cfgfile"
depend() {
......@@ -41,15 +44,23 @@ stop_pre() {
reload() {
pidfile=$(config_get "pid" "$pidfile")
ebegin "Reloading $SVCNAME"
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" "$config_file")"
local val="$(sed -En "s|^$key\s*=\s*(.*)\s*$|\1|p" "$cfgfile")"
echo "${val:-$default}"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment