Skip to content

Instantly share code, notes, and snippets.

@Pierozi
Created July 25, 2015 17:55
Show Gist options
  • Save Pierozi/e1a164d5f93d86b1861c to your computer and use it in GitHub Desktop.
Save Pierozi/e1a164d5f93d86b1861c to your computer and use it in GitHub Desktop.
luncher script for Isso
#!/bin/sh
### BEGIN INIT INFO
# Provides: isso
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: lightweight Disqus alternative
### END INIT INFO
EXEC=/usr/local/bin/isso
EXEC_OPTS="-c /etc/isso.ini run"
RUNAS=isso
PIDFILE=/var/run/isso.pid
start() {
if [ -f $PIDFILE ];then
PID=$(cat $PIDFILE)
ps -p $PID > /dev/null 2>&1
if [ $? -eq "0" ];then
echo "Process already running with PID $PID"
exit
fi
fi
echo 'Starting service…' >&2
start-stop-daemon --start --chuid $RUNAS --background --make-pidfile --pidfile $PIDFILE \
--exec $EXEC -- $EXEC_OPTS
}
stop() {
if [ ! -f $PIDFILE ];then
echo "Service already stop"
exit
fi
echo 'Stopping service…' >&2
start-stop-daemon --stop --chuid $RUNAS --pidfile $PIDFILE
rm $PIDFILE
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 2
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment