Skip to content

Instantly share code, notes, and snippets.

@nazoking
Created August 26, 2011 15:27
Show Gist options
  • Save nazoking/1173662 to your computer and use it in GitHub Desktop.
Save nazoking/1173662 to your computer and use it in GitHub Desktop.
stone 起動スクリプト(cent os)
#!/bin/bash
# /etc/init.d/stone として保存する。
# 設定ファイルは /etc/stone.conf
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/stone ]; then
. /etc/sysconfig/stone
fi
prog="stone"
pidfile=${PIDFILE-/var/run/stone.pid}
lockfile=${LOCKFILE-/var/lock/subsys/stone}
stone=${STONE-/usr/local/bin/stone}
conffile=/etc/stone.conf
start() {
if [ `whoami` != 'root' ]; then
echo root only
RETVAL=1
failure;
return $RETVAL
fi
echo -n $"Starting $prog: "
daemon $stone -l -D -i $pidfile -C $conffile
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
failure;
fi;
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
if [ -f $pidfile ]; then
killproc -p ${pidfile} $stone
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
failure;
fi;
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
else
echo no pid $pidfile
RETVAL=1
failure;
fi
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment