1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
#! /bin/sh
### BEGIN INIT INFO
# Provides: slash
# Required-Start: $sylog
# Required-Stop: $syslog
# Should-Start: $local_fs apache
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts the slashd
# Description: Starts the slash daemon which generates the static pages
# for all installed slash sites
### END INIT INFO
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/slashd
NAME=slash
DESC=slashd
# Slash home
DATADIR=/etc/slash
SLASHD=/usr/sbin/slashd
SLASHSITE=$DATADIR/slash.sites
# This is where you store the running PID of the slashd's you start
# Under Redhat people like to place this in /var/run
RUNNING_PID=/var/run
# To figure out where things are...
export TZ=GMT
WHICH_CAT=`which cat`
WHICH_CUT=`which cut`
test -f $DAEMON || exit 0
GRAB_CONFIG=`$WHICH_CAT $SLASHSITE | $WHICH_CUT -d"#" -f1`
if [ -z "`echo $GRAB_CONFIG | grep :`" ]; then
echo "NOT Starting/stopping slashd: No sites in $SLASHSITE";
exit 0;
fi
case "$1" in
start)
echo -n "Starting $DESC: "
cd $DATADIR
for server_name in $GRAB_CONFIG
do
SERVER_NAME=`echo $server_name |$WHICH_CUT -d":" -f1`
USERNAME=`echo $server_name |$WHICH_CUT -d":" -f2`
echo -n "Starting slashd $SERVER_NAME: "
# There are differing syntaxes of 'su' between OSes
# and even between different distributions of the same
# OS. If you have an OS that isn't listed here (or is
# a different case of one listed here [ie Red Hat Linux,
# Debian Linux]) please add in the necessary logic and
# send in a patch. Thanks!
#
# - Slashteam (slashteam@osdn.com)
# if you aren't using GMT for internal dates, please change
# the appropriate lines, below.
if [ "$OS" = "FreeBSD" ] ; then
su - $USERNAME "-c 'TZ=GMT $SLASHD $SERVER_NAME'" &
elif [ "$OS" = "Linux" ] ; then
su - $USERNAME -c "TZ=GMT $SLASHD $SERVER_NAME" &
else
TZ=GMT $SLASHD $SERVER_NAME &
fi
# this is handled by slashd
# echo $! > $RUNNING_PID/site/$SITENAME/logs/slashd.pid
done
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
cd $DATADIR
for server_name in $GRAB_CONFIG
do
SERVER_NAME=`echo $server_name |$WHICH_CUT -d":" -f1`
USERNAME=`echo $server_name |$WHICH_CUT -d":" -f2`
SITENAME=`echo $server_name |$WHICH_CUT -d":" -f3`
if [ -f $RUNNING_PID/slashd.$SITENAME.pid ] ;then
echo -n "Stopping slashd $SERVER_NAME: "
if ! kill `cat $RUNNING_PID/slashd.$SITENAME.pid` ;then
echo -n "...using kill -9..."
sleep 3
kill -9 `cat $RUNNING_PID/slashd.$SITENAME.pid`
rm -f $RUNNING_PID/slashd.$SITENAME.pid
fi
# this is handled by slashd
# rm -f $RUNNING_PID/site/$SITENAME/logs/slashd.pid
echo "ok."
else
echo "Slashd $SERVER_NAME has no PID file"
fi
done
echo "$NAME."
;;
#reload)
#
# If the daemon can reload its config files on the fly
# for example by sending it SIGHUP, do it here.
#
# If the daemon responds to changes in its config file
# directly anyway, make this a do-nothing entry.
#
# echo "Reloading $DESC configuration files."
# start-stop-daemon --stop --signal 1 --quiet --pidfile \
# /var/run/$NAME.pid --exec $DAEMON
#;;
restart|force-reload)
#
# If the "reload" option is implemented, move the "force-reload"
# option to the "reload" entry above. If not, "force-reload" is
# just the same as "restart".
#
echo -n "Restarting $DESC: "
for server_name in $GRAB_CONFIG
do
SITENAME=`echo $server_name |$WHICH_CUT -d":" -f3`
start-stop-daemon --stop --quiet --pidfile \
/var/run/$NAME.$SITENAME.pid --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --pidfile \
/var/run/$NAME.$SITENAME.pid --exec $DAEMON
done
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
|