scripts/runbot
author Markus Bröker <mbroeker@largo.dyndns.tv>
Sat, 13 Dec 2008 15:42:15 +0100
changeset 26 767f79e69de1
parent 0 586472add385
child 27 4a2f7a1492ab
permissions -rwxr-xr-x
Debian QoS - Lintian Checks committer: Markus Bröker <mbroeker@largo.homelinux.org>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     1
#!/bin/sh
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     2
26
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
     3
### BEGIN INIT INFO
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
     4
# Provides:          mcbot
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
     5
# Required-Start:    $remote_fs $syslog
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
     6
# Required-Stop:     $remote_fs $syslog
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
     7
# Default-Start:     2 3 4 5
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
     8
# Default-Stop:      0 1 6
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
     9
# Short-Description: IRC BOT mcbot 
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    10
# Description:       IRC BOT mcbot
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    11
### END INIT INFO
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    12
0
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    13
BINARY="mcbot"
26
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    14
DIRECTORY="/usr/sbin/"
0
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    15
LANGUAGE="de_DE.UTF-8"
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    16
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    17
[[ ! -x "${DIRECTORY}/${BINARY}" ]] && exit 0
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    18
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    19
start() {
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    20
	echo -n "Starting ${BINARY}"
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    21
	su - nobody -c "LANG=$LANGUAGE ${DIRECTORY}/${BINARY} &>/var/lib/nobody/mcbot-`date "+%d-%m-%y"`.log &"
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    22
	if [ "$?" == 0 ]; then
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    23
		echo " [started]"
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    24
	fi
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    25
}
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    26
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    27
stop() {
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    28
	echo -n "Stopping ${BINARY}"
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    29
	pid=`pidof ${BINARY}`
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    30
	if [ "$pid" != "" ]; then
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    31
		kill -TERM `pidof ${BINARY}`
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    32
		sleep 5
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    33
	fi
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    34
	echo " [stopped]"
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    35
}
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    36
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    37
status() {
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    38
	pid="`pidof ${BINARY}`"
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    39
	if [ "$pid" != "" ]; then
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    40
		echo "${BINARY} is started as ${pid}"
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    41
	else
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    42
		echo "${BINARY} is not running"
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    43
	fi
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    44
}
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    45
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    46
case "$1" in
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    47
	start)
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    48
		start
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    49
	;;
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    50
	stop)
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    51
		stop
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    52
	;;
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    53
	status)
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    54
		status
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    55
	;;
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    56
	restart)
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    57
		echo "Restarting ${BINARY}"
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    58
		stop
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    59
		start
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    60
	;;
26
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    61
	force-reload)
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    62
		echo "Force reload stub"
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    63
		stop
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    64
		start
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    65
	;;
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    66
0
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    67
	*)
26
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    68
		echo "Usage: start|stop|restart|status|force-reload"
0
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    69
	;;
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    70
esac
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    71
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    72
exit 0