aboutsummaryrefslogtreecommitdiff
path: root/network/znc/rc.znc
diff options
context:
space:
mode:
Diffstat (limited to 'network/znc/rc.znc')
-rw-r--r--network/znc/rc.znc62
1 files changed, 62 insertions, 0 deletions
diff --git a/network/znc/rc.znc b/network/znc/rc.znc
new file mode 100644
index 0000000000000..85d58929ceb81
--- /dev/null
+++ b/network/znc/rc.znc
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+# Start/stop/restart znc
+
+# User account under which ZNC should run; only change this if you
+# know what you are doing :-)
+ZNC_USER="_ZNC_USER_"
+
+# First, a sanity check
+if [[ ! -e /etc/znc/configs/znc.conf ]]; then
+ echo "Warning: /etc/znc/configs/znc.conf does not exist."
+ echo "You should create a config file by running the following command:"
+ echo " su - $ZNC_USER -c '/usr/bin/znc --makeconf --datadir=/etc/znc'"
+ exit 1
+fi
+
+znc_start() {
+ if [[ -e /var/lock/znc ]]; then
+ echo "ZNC is already running, or there is a stale lock file at "
+ echo "/var/lock/znc - if you are sure that znc is not already "
+ echo "running, then remove the lock and try again."
+ return 1
+ else
+ su - $ZNC_USER -c '/usr/bin/znc --datadir /etc/znc' && touch /var/lock/znc
+ return 0
+ fi
+}
+
+znc_stop() {
+ killall znc 2>/dev/null
+ RETVAL=$?
+ if (( "$RETVAL" != 0 )); then
+ echo "ZNC does not appear to be running..."
+ else
+ rm -f /var/lock/znc
+ fi
+ return $RETVAL
+}
+
+znc_restart() {
+ znc_stop
+ sleep 1
+ znc_start
+}
+
+case "$1" in
+ 'start')
+ znc_start
+ ;;
+ 'stop')
+ znc_stop
+ ;;
+ 'restart')
+ znc_restart
+ ;;
+ *)
+ echo "Usage: $0 start|stop|restart"
+ exit 1
+esac
+
+exit $?
+