aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2017-10-13 01:27:02 +0200
committerJakub Jirutka <jakub@jirutka.cz>2017-10-13 02:14:23 +0200
commit8bc3b1bc8c80b7c1d4635dc53255610e05326147 (patch)
tree0251b83663d541e109089044dfd23f024efbee9e
parent6012f31435a177749fad326a37dfbb313b85ff5a (diff)
downloadaports-8bc3b1bc8c80b7c1d4635dc53255610e05326147.tar.bz2
main/znc: improve runscript
-rw-r--r--main/znc/APKBUILD4
-rw-r--r--main/znc/znc.confd10
-rw-r--r--main/znc/znc.initd50
3 files changed, 36 insertions, 28 deletions
diff --git a/main/znc/APKBUILD b/main/znc/APKBUILD
index 876926f..55e9b0e 100644
--- a/main/znc/APKBUILD
+++ b/main/znc/APKBUILD
@@ -105,5 +105,5 @@ _mv_to_sub() {
}
sha512sums="d78603ac86d1fb92cdf591b1eb6d32fa19b0e39414bd69e1300c537051612ae590c43d3b8e4dd598cdff605bf3aa1d3d5d806edd428d15d50f733e1670f3e626 znc-1.6.5.tar.gz
-3287affd90f0048a7e790179d97ac9964498cc87f833afb97c6298abfbdbdf1131edd1211b3b64290a862ae4a768f63c346c274a18664a2e22e2815632a726c2 znc.initd
-352f18d64cbfbd5970c859f2ae2290c0ddafcbd8f1bb5d74f33976bc8388f65a75f8a9a73a093fbac12f2d243d4bcf74380bbb3aaab8d68f7bf4eab7ce3bea46 znc.confd"
+47f9bd00f07861e195333d2cda5b1c7386e2324a1842b890837a7936a94b65b7a269f7fee656a522ec86b58a94bd451a2a3629bd6465578681b8d0733c2c77dc znc.initd
+00360f9b487ed5a9d50c85ce597e65c89cf869cabb893c294d0bc7fcd88f9610ecb63ba6df7af1ba1dd977b6d5b05da625a3ee799a46d381f17ac04b976a1f29 znc.confd"
diff --git a/main/znc/znc.confd b/main/znc/znc.confd
index 9681f8d..cb68523 100644
--- a/main/znc/znc.confd
+++ b/main/znc/znc.confd
@@ -1,7 +1,7 @@
-# /etc/conf.d/znc
+# Configuration for /etc/conf.d/znc
-# Location of the znc configuration folder
-ZNC_CONF="/var/lib/znc"
+# Location of the znc configuration folder.
+#datadir="/var/lib/znc"
-# User to run znc as
-ZNC_USER="znc"
+# User to run znc as.
+#command_user="znc"
diff --git a/main/znc/znc.initd b/main/znc/znc.initd
index a8a9423..b6c5279 100644
--- a/main/znc/znc.initd
+++ b/main/znc/znc.initd
@@ -1,39 +1,47 @@
#!/sbin/openrc-run
-# Copyright 1999-2012 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/net-irc/znc/files/znc.initd,v 1.1 2012/11/21 18:11:31 wired Exp $
-extra_commands="config"
+# Upper case variables are here for backward compatibility.
+: ${command_user:=${ZNC_USER:-"znc"}}
+: ${datadir:=${ZNC_CONF:-"/var/lib/znc"}}
+
extra_started_commands="reload save"
+extra_stopped_commands="setup"
+description_reload="Reload ZNC configuration from disk"
+description_save="Save ZNC configuration to disk"
+description_setup="Interactively create a new config"
+
+command="/usr/bin/znc"
+command_args="-f -d $datadir ${command_args:-}"
+command_background="yes"
+pidfile="/run/$RC_SVCNAME.pid"
depend() {
need net
}
-start() {
- ebegin "Starting ZNC"
- start-stop-daemon --start --user ${ZNC_USER} --name znc \
- --exec /usr/bin/znc -- -d ${ZNC_CONF}
- eend $?
+start_pre() {
+ if [ ! -f "$datadir"/configs/znc.conf ]; then
+ eerror "File $datadir/configs/znc.conf does not exist!"
+ eerror "Run 'rc-service $RC_SVCNAME setup' to create ZNC configuration."
+ return 1
+ fi
}
-stop() {
- ebegin "Stopping ZNC"
- start-stop-daemon --signal SIGINT --name znc \
- --exec /usr/bin/znc -- -d ${ZNC_CONF}
+reload() {
+ ebegin "Reloading ZNC configuration from disk"
+ start-stop-daemon --signal SIGHUP --pidfile "$pidfile"
eend $?
}
-reload() {
- ebegin "Reloading ZNC Configuration File from Disk"
- start-stop-daemon --signal SIGHUP --name znc \
- --exec /usr/bin/znc -- -d ${ZNC_CONF}
+save() {
+ ebegin "Saving ZNC configuration to disk"
+ start-stop-daemon --signal SIGUSR1 --pidfile "$pidfile"
eend $?
}
-save() {
- ebegin "Saving ZNC Configuration File to Disk"
- start-stop-daemon --signal SIGUSR1 --name znc \
- --exec /usr/bin/znc -- -d ${ZNC_CONF}
+setup() {
+ ebegin "Creating a new ZNC config"
+ checkpath -d -m 750 -o "$command_user" "$datadir"
+ su "$command_user" -s /bin/sh -c "$command $command_args --makeconf"
eend $?
}