Skip to content

Instantly share code, notes, and snippets.

@tlvince
Created October 5, 2011 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlvince/1266098 to your computer and use it in GitHub Desktop.
Save tlvince/1266098 to your computer and use it in GitHub Desktop.
znc init script for Arch Linux
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
get_pid() {
pidof /usr/bin/znc
}
case "$1" in
start)
stat_busy "Starting znc"
PID=$(get_pid)
if [ -z "$PID" ]; then
su -s /bin/sh -c '/usr/bin/znc --datadir /etc/znc' 'znc' > /dev/null
if [ $? -gt 0 ]; then
stat_fail
exit 1
else
add_daemon znc
stat_done
fi
else
stat_fail
exit 1
fi
;;
stop)
stat_busy "Stopping znc"
PID=$(get_pid)
[ ! -z "$PID" ] && kill $PID
if [ $? -gt 0 ]; then
stat_fail
exit 1
else
rm_daemon znc
stat_done
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment