From 663d500d91b0e3c7b75f282eb6f54f25e15d2f95 Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Sun, 15 Dec 2019 19:34:16 +0100 Subject: community/stunnel: improve init script --- community/stunnel/APKBUILD | 4 ++-- community/stunnel/stunnel.initd | 25 ++++++++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/community/stunnel/APKBUILD b/community/stunnel/APKBUILD index eebedb379e..2a38611afa 100644 --- a/community/stunnel/APKBUILD +++ b/community/stunnel/APKBUILD @@ -4,7 +4,7 @@ # Maintainer: Jakub Jirutka 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" diff --git a/community/stunnel/stunnel.initd b/community/stunnel/stunnel.initd index 6b8ab0335b..a625d081c7 100644 --- a/community/stunnel/stunnel.initd +++ b/community/stunnel/stunnel.initd @@ -1,16 +1,19 @@ #!/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}" } -- cgit v1.2.3