~ubuntu-branches/ubuntu/hardy/steam/hardy

« back to all changes in this revision

Viewing changes to distrib/debian-3.1/steam.init

  • Committer: Bazaar Package Importer
  • Author(s): Alain Schroeder
  • Date: 2006-11-21 16:03:12 UTC
  • mfrom: (2.1.4 feisty)
  • Revision ID: james.westby@ubuntu.com-20061121160312-nf96y6nihzsyd2uv
Tags: 2.2.31-3
Add patch to prevent inconsistent data after shutdown.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
### BEGIN INIT INFO
 
3
# Provides:          steam
 
4
# Required-Start:    $local_fs $remote_fs
 
5
# Required-Stop:     $local_fs $remote_fs
 
6
# Default-Start:     2 3 4 5
 
7
# Default-Stop:      S 0 1 6
 
8
# Short-Description: sTeam server init script
 
9
# Description:       This script controls the open-sTeam server
 
10
### END INIT INFO
 
11
 
 
12
# Author: Robert Hinn <exodus@uni-paderborn.de>
 
13
 
 
14
# PATH should only include /usr/* if it runs after the mountnfs.sh script
 
15
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 
16
DESC="sTeam server"
 
17
NAME=steam
 
18
DAEMON_DIR=/usr/share/steam
 
19
DAEMON=start
 
20
DAEMON_ARGS="--restart"
 
21
DAEMON_STOP=stop
 
22
PIDFILE=/var/run/$NAME.pid
 
23
SCRIPTNAME=/etc/init.d/$NAME
 
24
 
 
25
 
 
26
# Exit if the package is not installed
 
27
[ -x "/$DAEMON_DIR/$DAEMON" ] || exit 0
 
28
 
 
29
# Read configuration variable file if it is present
 
30
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
 
31
 
 
32
# Load the VERBOSE setting and other rcS variables
 
33
[ -f /etc/default/rcS ] && . /etc/default/rcS
 
34
 
 
35
# Define LSB log_* functions.
 
36
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
 
37
#. /lib/lsb/init-functions
 
38
# (this is not available in Debian Sarge, yet, so we define these functions:)
 
39
log_daemon_msg () {
 
40
    if [ -z "${1:-}" ]; then
 
41
        return 1
 
42
    fi
 
43
 
 
44
    if [ -z "${2:-}" ]; then
 
45
        echo -n "$1:"
 
46
        return
 
47
    fi
 
48
    
 
49
    echo -n "$1: $2"
 
50
}
 
51
#
 
52
log_end_msg () {
 
53
    # If no arguments were passed, return
 
54
    [ -z "${1:-}" ] && return 1
 
55
    if [ $1 -eq 0 ]; then
 
56
        echo "."
 
57
    else
 
58
        echo " failed!"
 
59
    fi
 
60
    return $1
 
61
}
 
62
 
 
63
 
 
64
# try to detect a java runtime:
 
65
if [ -z $JAVA_HOME ] && [ -e /etc/alternatives/java ]; then
 
66
        # the BACKTICK is just a workaround to allow 'cut' to look for '`':
 
67
        BACKTICK="\`"
 
68
        JAVA_HOME="`LANG=C file -b /etc/alternatives/java | cut -f 2 -d "$BACKTICK" | cut -f 1 -d \' | sed -e 's/\/bin\/java$//'`"
 
69
        # Only export if this is actually a directory:
 
70
        if [ -d "$JAVA_HOME" ]; then
 
71
            export JAVA_HOME
 
72
        fi
 
73
fi
 
74
 
 
75
 
 
76
#
 
77
# Function that starts the daemon/service
 
78
#
 
79
do_start()
 
80
{
 
81
    [ -f $PIDFILE ] && return 1
 
82
    cd "$DAEMON_DIR" && "./$DAEMON" "$DAEMON_ARGS" --pid="$PIDFILE" > /dev/null 2>&1 &
 
83
    for x in 1 2 3 4 5 6 7 8 9 10; do
 
84
        [ -f $PIDFILE ] && return 0
 
85
        sleep 1
 
86
    done
 
87
    return 2
 
88
}
 
89
 
 
90
#
 
91
# Function that stops the daemon/service
 
92
#
 
93
do_stop()
 
94
{
 
95
    [ -f "$PIDFILE" ] || return 1
 
96
    cd "$DAEMON_DIR" && ./$DAEMON_STOP --pid="$PIDFILE" > /dev/null 2>&1 &
 
97
    for x in 1 2 3 4 5 6 7 8 9 10; do
 
98
        [ -f "$PIDFILE" ] || return 0
 
99
        sleep 1
 
100
    done
 
101
    return 2
 
102
}
 
103
 
 
104
#
 
105
# Function that sends a SIGHUP to the daemon/service
 
106
#
 
107
do_reload() {
 
108
        #
 
109
        # If the daemon can reload its configuration without
 
110
        # restarting (for example, when it is sent a SIGHUP),
 
111
        # then implement that here.
 
112
        #
 
113
        #start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
 
114
        return 0
 
115
}
 
116
 
 
117
case "$1" in
 
118
  start)
 
119
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
 
120
        do_start
 
121
        case "$?" in
 
122
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
 
123
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
 
124
        esac
 
125
        ;;
 
126
  stop)
 
127
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
 
128
        do_stop
 
129
        case "$?" in
 
130
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
 
131
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
 
132
        esac
 
133
        ;;
 
134
  #reload|force-reload)
 
135
        #
 
136
        # If do_reload() is not implemented then leave this commented out
 
137
        # and leave 'force-reload' as an alias for 'restart'.
 
138
        #
 
139
        #log_daemon_msg "Reloading $DESC" "$NAME"
 
140
        #do_reload
 
141
        #log_end_msg $?
 
142
        #;;
 
143
  restart|force-reload)
 
144
        #
 
145
        # If the "reload" option is implemented then remove the
 
146
        # 'force-reload' alias
 
147
        #
 
148
        log_daemon_msg "Restarting $DESC" "$NAME"
 
149
        do_stop
 
150
        case "$?" in
 
151
          0|1)
 
152
                do_start
 
153
                case "$?" in
 
154
                        0) log_end_msg 0 ;;
 
155
                        1) log_end_msg 1 ;; # Old process is still running
 
156
                        *) log_end_msg 1 ;; # Failed to start
 
157
                esac
 
158
                ;;
 
159
          *)
 
160
                # Failed to stop
 
161
                log_end_msg 1
 
162
                ;;
 
163
        esac
 
164
        ;;
 
165
  *)
 
166
        #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
 
167
        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
 
168
        exit 3
 
169
        ;;
 
170
esac
 
171
 
 
172
: