Skip to content

Instantly share code, notes, and snippets.

@guillochon
Last active Nov 12, 2017
Embed
What would you like to do?
#!/bin/bash
#
# astrochats Astrochats Slackin
#
# chkconfig: 345 70 30
# Source function library.
. /etc/init.d/functions
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=slackin
LOCKFILE=/var/lock/subsys/astrochats
LOGFILE=/var/log/astrochats.log
PIDFILE=/var/run/astrochats.pid
SLACKKEY=$(cat /root/slackkey)
start() {
echo -n "Starting astrochats: "
$DAEMON astrochats $SLACKKEY --port 30861 --interval 60000 --hostname localhost > $LOGFILE 2>&1 &
PID=$!
echo $PID > $PIDFILE
RETVAL=$?
echo -n
[ $RETVAL = 0 ] && echo -e '[\e[32m OK \e[m]'
[ $RETVAL = 0 ] && touch $LOCKFILE
return $RETVAL
}
stop() {
echo -n "Shutting down astrochats: "
killproc -p $PIDFILE node
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f $LOCKFILE $PIDFILE
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
*)
echo "Usage: oacapi {start|stop|status|restart}"
exit 1
;;
esac
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment