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

« back to all changes in this revision

Viewing changes to distrib/suse/init.d/steam.in

  • 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
#
 
3
# /etc/init.d/@brand@
 
4
#
 
5
#   and its symbolic link
 
6
#
 
7
# /usr/sbin/rc@brand@
 
8
#
 
9
### BEGIN INIT INFO
 
10
# Provides:       steam
 
11
# Required-Start: $network $remote_fs $mysqld
 
12
# Required-Stop:
 
13
# Default-Start:  2 3 5
 
14
# Default-Stop:
 
15
# Description:    Start the open-sTeam server
 
16
### END INIT INFO
 
17
 
 
18
# Shell functions sourced from /etc/rc.status:
 
19
#      rc_check         check and set local and overall rc status
 
20
#      rc_status        check and set local and overall rc status
 
21
#      rc_status -v     ditto but be verbose in local rc status
 
22
#      rc_status -v -r  ditto and clear the local rc status
 
23
#      rc_failed        set local and overall rc status to failed
 
24
#      rc_failed <num>  set local and overall rc status to <num>
 
25
#      rc_reset         clear local rc status (overall remains)
 
26
#      rc_exit          exit appropriate to overall rc status
 
27
. /etc/rc.status
 
28
 
 
29
# First reset status of this service
 
30
rc_reset
 
31
 
 
32
# Return values acc. to LSB for all commands but status:
 
33
# 0 - success
 
34
# 1 - generic or unspecified error
 
35
# 2 - invalid or excess argument(s)
 
36
# 3 - unimplemented feature (e.g. "reload")
 
37
# 4 - insufficient privilege
 
38
# 5 - program is not installed
 
39
# 6 - program is not configured
 
40
# 7 - program is not running
 
41
 
42
# Note that starting an already running service, stopping
 
43
# or restarting a not-running service as well as the restart
 
44
# with force-reload (in case signalling is not supported) are
 
45
# considered a success.
 
46
 
 
47
prog="@brand@"
 
48
pidfile="/var/run/@brand@.pid"
 
49
steamhome="@steamdir@"
 
50
configdir="@configdir@"
 
51
logdir="@logdir@"
 
52
JAVA_HOME="@javahome@"
 
53
export JAVA_HOME
 
54
 
 
55
mode=$1 # start or stop
 
56
 
 
57
# Safeguard (relative paths, core dumps..)
 
58
cd $steamhome
 
59
 
 
60
case "$1" in
 
61
    start)
 
62
        # exit gracefully, if we are already running
 
63
        checkproc $prog && echo -n "Starting service @brand@" && \
 
64
        rc_status -v && rc_exit
 
65
 
 
66
        echo -n "Starting service @brand@"
 
67
 
 
68
        cd $steamhome && ./start --restart --pid="$pidfile" &> $logdir/init.d_start.log &
 
69
 
 
70
        for((i=0; i<50; i++)); do
 
71
           sleep 0.2
 
72
           test -e $pidfile && i='' && break
 
73
        done
 
74
 
 
75
        test -z "$i" || rc_failed
 
76
 
 
77
        # Rmember status and be verbose
 
78
        rc_status -v
 
79
        ;;
 
80
 
 
81
    stop)
 
82
        echo -n "Shutting down service @brand@"
 
83
        cd $steamhome && ./stop --pid="$pidfile" &> $logdir/init.d_stop.log
 
84
        #killproc -p $pidfile -TERM $prog
 
85
 
 
86
        # Remember status and be verbose
 
87
        rc_status -v
 
88
        ;;
 
89
 
 
90
    try-restart)
 
91
        ## Stop the service and if this succeeds (i.e. the 
 
92
        ## service was running before), start it again.
 
93
        ## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
 
94
        $0 status >/dev/null &&  $0 restart
 
95
 
 
96
        # Remember status and be quiet
 
97
        rc_status
 
98
        ;;
 
99
 
 
100
    restart|force-reload|reload)
 
101
        echo "Restarting service @brand@"
 
102
        $0 stop
 
103
        $0 start
 
104
 
 
105
        rc_status
 
106
        ;;
 
107
 
 
108
    check|status)
 
109
        echo -n "Checking for service @brand@: "
 
110
        ## Check status with checkproc(8), if process is running
 
111
        ## checkproc will return with exit status 0.
 
112
 
 
113
        # Status has a slightly different for the status command:
 
114
        # 0 - service running
 
115
        # 1 - service dead, but /var/run/  pid  file exists
 
116
        # 2 - service dead, but /var/lock/ lock file exists
 
117
        # 3 - service not running
 
118
 
 
119
        # NOTE: checkproc returns LSB compliant status values.
 
120
        checkproc $prog
 
121
        rc_status -v
 
122
        ;;
 
123
 
 
124
    *)
 
125
        echo "Usage: $0 {start|stop|status|reload|restart|try-restart|force-reload}"
 
126
        exit 1
 
127
        ;;
 
128
esac
 
129
rc_exit