diaspora/pkg/fedora/diaspora-wsd
2010-10-20 22:05:42 +02:00

103 lines
2 KiB
Bash
Executable file

#!/bin/bash
#
# /etc/rc.d/init.d/diaspora-wsd
#
# Starts the diaspora websocket daemon
#
# chkconfig: - 80 80
# description: Diaspora websocket daemon
### BEGIN INIT INFO
# Provides: diaspora-wsd
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Should-Start: $remote_fs
# Should-Stop: $remote_fs
# Default-Start:
# Default-Stop: 0 1 2 3 4 5 6
# Short-Description: start and stop Diaspora websocket server
# Description: The websocket server provides websocket services for
# diaspora.
### END INIT INFO
# Source function library.
. /etc/init.d/functions
if [ -f /etc/sysconfig/diaspora-wsd -a $UID -eq 0 ]; then
. /etc/sysconfig/diaspora-wsd
fi
# Note: this line is patched by installation scripts.
cd /usr/share/diaspora
RETVAL=0
prog="Diaspora websocket server"
exec="script/websocket_server.rb"
pidfile="/var/run/diaspora/diaspora-wsd"
lockfile="/var/lock/subsys/diaspora-wsd"
logfile="/var/log/diaspora/diaspora-wsd.log"
[ -n "$OPTIONS" ] && OPTIONS=" $OPTIONS"
ruby_cmd="ruby -C $PWD $exec$OPTIONS"
start() {
[ $UID -eq 0 ] || exit 4
[ -f $exec ] || exit 5
echo -n $"Starting $prog: "
daemon --pidfile $pidfile "$ruby_cmd >>$logfile 2>&1 &"
RETVAL=$?
echo
if test $RETVAL = 0; then
touch $lockfile
pgrep -f "$ruby_cmd" > $pidfile || {
echo "Warning: cannot find running diaspora-webserver"
exit 7
}
fi
}
stop() {
[ $UID -eq 0 ] || exit 4
echo -n $"Stopping $prog: "
killproc -p $pidfile $exec
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f $lockfile
echo
}
#
# See how we were called.
#
case "$1" in
start)
start
;;
stop)
stop
;;
force-reload|restart)
stop
sleep 1
start
RETVAL=$?
;;
condrestart|try-restart)
if [ -f $lockfile ]; then
stop
sleep 3
start
fi
;;
status)
status -p $pidfile $exec
RETVAL=$?
;;
*)
echo $"Usage: $0 {condrestart|try-restart|start|stop|restart|force-reload|status}"
RETVAL=2
[ "$1" = 'usage' ] && RETVAL=0
esac
exit $RETVAL