Skip to content

Instantly share code, notes, and snippets.

@ik5
Last active August 10, 2016 03:19
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save ik5/6286435 to your computer and use it in GitHub Desktop.
Save ik5/6286435 to your computer and use it in GitHub Desktop.
Adhearsion init script
#!/bin/bash
### BEGIN INIT INFO
# Provides: ahn
# Required-Start: ahn daemon
# Required-Stop: ahn daemon
# chkconfig: 2345 91 60
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Adhearsion daemon
# Description: This is a Adhearsion daemon init script
### END INIT SCRIPT
# Source function library.
[ -e /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions
NAME=Adhearsion
AHN=/usr/bin/ahn
APP_PATH=/var/<replace me>/
pid="$(pidof ahn)"
case "$1" in
start)
$AHN daemon $APP_PATH
;;
stop)
$AHN stop $APP_PATH
;;
restart)
$AHN restart $APP_PATH
;;
rotate)
[ -n "$pid" ] && (kill -1 $pid ; echo "Sent rotation signal" ) || echo "Adhearsion not running"
;;
trace)
[ -n "$pid" ] && (kill -14 $pid ; echo "Toggeled trace signal" ) || echo "Adhearsion not running"
;;
status)
echo -n "Adhearsion is "
[ -n "$pid" ] && echo "running" || echo "not running"
;;
*)
echo "Usage: ahn {start|stop|restart|rotate|trace|status}"
exit 1
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment