source: trunk/init.d @ 59

Last change on this file since 59 was 59, checked in by bas, 12 years ago

remove debug statement

  • Property svn:keywords set to Id URL
File size: 4.1 KB
Line 
1#!/bin/sh
2#set -x
3#
4# Start stop script for TORQUE
5#
6# Authors : Bas van der Vlies & Jaap Dijkshoorn
7#           Kilian Cavalotti
8#
9# SVN INFO:
10#       $Id: init.d 59 2012-07-05 13:32:16Z bas $
11#               $URL: trunk/init.d $
12#
13### BEGIN INIT INFO
14# Provides:          torque
15# Required-Start:    $remote_fs $network
16# Required-Stop:     $remote_fs $network
17# Default-Start:     2 3 4 5
18# Default-Stop:      0 1 6
19# Short-Description: Start daemon at boot time
20# Description:       pbs_mon, pbs_sched and pbs_server
21### END INIT INFO
22#
23DESC="TORQUE servers"
24TORQUE_DIR=/usr/sbin
25DEFAULT=/etc/default/torque
26SPOOLDIR=/var/spool/torque
27
28# Some useful defaults can be overriden in the DEFAULT file
29#
30PBS_MOM_RESTART_OPTS='-p'
31PBS_MOM_OPTS=''
32PBS_SCHED_OPTS=''
33PBS_SERVER_OPTS='-a t'
34PBS_TRQAUTH_OPTS=""
35
36if [ ! -f $DEFAULT ]
37then
38        echo "No file [$DEFAULT]"
39        exit 0
40fi
41. $DEFAULT
42
43## Start functions
44start_server() {
45        start-stop-daemon --start --quiet --exec $TORQUE_DIR/pbs_server -- $PBS_SERVER_OPTS
46        echo " pbs server"
47}
48
49start_sched() {
50        start-stop-daemon --start --quiet --exec $TORQUE_DIR/pbs_sched -- $PBS_SCHED_OPTS
51        echo " pbs sched"
52}
53
54start_mom() {
55        start-stop-daemon --start --quiet --exec $TORQUE_DIR/pbs_mom -- $PBS_MOM_OPTS
56        echo " pbs mom"
57}
58
59start_trqauth() {
60        start-stop-daemon --start --quiet --exec $TORQUE_DIR/trqauthd -- $PBS_TRQAUTH_OPTS
61        echo " pbs trqauth"
62}
63
64start_daemons() {
65    check_perms
66
67    ## Always start trqauth daemon
68    #
69    start_trqauth
70
71    if [ "$PBS_SERVER" = "1" ] 
72    then
73        start_server
74    fi
75       
76    if [ "$PBS_SCHED" = "1" ]
77    then
78        start_sched
79    fi
80       
81   if [ "$PBS_MOM" = "1" ]
82   then
83        start_mom
84   fi
85}
86
87## Stop functions
88
89stop_server() {
90        start-stop-daemon --retry 5 --stop --quiet --exec $TORQUE_DIR/pbs_server
91        echo " pbs server"
92        echo " waiting for server to shutdown"
93        sleep 5
94}
95
96stop_sched() {
97        start-stop-daemon --retry 5 --stop --quiet --exec $TORQUE_DIR/pbs_sched
98        echo " pbs sched"
99}
100
101stop_mom() {
102        start-stop-daemon --retry 5 --stop --quiet --exec $TORQUE_DIR/pbs_mom
103        echo " pbs mom"
104}
105
106stop_trqauth() {
107        start-stop-daemon --retry 5 --stop --quiet --exec $TORQUE_DIR/trqauthd
108        echo " pbs trqauth"
109}
110
111stop_daemons() {
112        if [ "$PBS_SERVER" = "1" ]
113        then
114                stop_server
115        fi
116       
117        if [ "$PBS_SCHED" = "1" ]
118        then
119                stop_sched
120        fi
121       
122        if [ "$PBS_MOM" = "1" ]
123        then
124                stop_mom
125        fi
126
127        stop_trqauth
128}
129
130## Check permissions and directories
131check_perms() {
132
133    check_dir() {
134        if [ ! -d "$1" ]; then
135            mkdir -m 1777 "$1"
136        else
137            chmod 1777 "$1"
138        fi
139    }
140
141    check_dir $SPOOLDIR/spool
142    check_dir $SPOOLDIR/undelivered
143}
144
145
146## Main
147case "$1" in
148        start)
149                echo "Starting $DESC: "
150                start_daemons
151        ;;
152
153        stop)
154                echo "Stopping $DESC: "
155                stop_daemons
156        ;;
157
158        restart)
159                echo "Restarting $DESC: "
160                stop_daemons
161                sleep 1
162                PBS_MOM_OPTS="$PBS_MOM_RESTART_OPTS"
163                start_daemons
164        ;;
165
166        restart-mom)
167                echo "Restarting pbs_mom: "
168                stop_mom
169                sleep 1 
170                PBS_MOM_OPTS="$PBS_MOM_RESTART_OPTS"
171                start_mom
172        ;;
173
174        restart-sched)
175                echo "Restarting pbs_sched: " 
176                stop_sched
177                sleep 1
178                start_sched
179        ;;
180
181
182        restart-server)
183                echo "Restarting pbs_server: "
184                stop_server
185                sleep 1
186                start_server
187        ;;
188
189        restart-server)
190                echo "Restarting pbs trqauthr: "
191                stop_trqauth
192                sleep 1
193                start_trqauth
194        ;;
195
196        *)
197                echo "Usage: $0 {restart|start|stop|restart-mom|restart-server|restart-sched|restart-trqauth}\n" >&2
198                exit 1
199        ;;
200esac
201
202exit 0
Note: See TracBrowser for help on using the repository browser.