Skip to content

Instantly share code, notes, and snippets.

@olsgreen
Created December 15, 2013 11:01
Show Gist options
  • Save olsgreen/7971582 to your computer and use it in GitHub Desktop.
Save olsgreen/7971582 to your computer and use it in GitHub Desktop.
CentOS Ghost Init Script.Requires daemonize to run.
#!/bin/sh
#
# ghost - this script starts and stops the ghost npm daemon
#
# chkconfig: - 85 15
# description: Ghost - just another blog
# processname: ghost
# pidfile: /var/run/ghost.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
ghost_path="/data/ghost"
node_path="/usr/bin/node"
prog="ghost"
lockfile="/var/lock/subsys/ghost"
pidfile="/var/run/ghost.pid"
start() {
echo -n $"Starting $prog: "
daemon /usr/sbin/daemonize -l $lockfile -p $pidfile -c $ghost_path $node_path index.js
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc -p $pidfile $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
rh_status() {
status $prog
}
case "$1" in
start)
$1
;;
stop)
$1
;;
restart)
$1
;;
status)
rh_$1
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 2
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment