source: trunk/init.d @ 25

Last change on this file since 25 was 25, checked in by bas, 15 years ago

changelog:

new upstream release 2.3.4

init.d:

  • made script LSBware

patches/apply:

  • commented gcc rlimit patch for version 2.3.4
  • Property svn:keywords set to Id URL
File size: 3.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 25 2008-11-11 14:16:55Z 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_OPTS='-p'
31PBS_SCHED_OPTS=''
32PBS_SERVER_OPTS='-a t'
33
34if [ ! -f $DEFAULT ]
35then
36        echo "No file [$DEFAULT]"
37        exit 0
38fi
39. $DEFAULT
40
41## Start functions
42start_server() {
43        start-stop-daemon --start --quiet --exec $TORQUE_DIR/pbs_server -- $PBS_SERVER_OPTS
44        echo " pbs server"
45}
46
47start_sched() {
48        start-stop-daemon --start --quiet --exec $TORQUE_DIR/pbs_sched -- $PBS_SCHED_OPTS
49        echo " pbs sched"
50}
51
52start_mom() {
53        start-stop-daemon --start --quiet --exec $TORQUE_DIR/pbs_mom -- $PBS_MOM_OPTS
54        echo " pbs mom"
55}
56
57start_daemons() {
58    check_perms
59
60        if [ "$PBS_SERVER" = "1" ]
61        then
62                start_server
63        fi
64
65        if [ "$PBS_SCHED" = "1" ]
66        then
67                start_sched
68        fi
69
70        if [ "$PBS_MOM" = "1" ]
71        then
72                start_mom
73        fi
74}
75
76## Stop functions
77
78stop_server() {
79        start-stop-daemon --retry 5 --stop --quiet --exec $TORQUE_DIR/pbs_server
80        echo " pbs server"
81        echo " waiting for server to shutdown"
82        sleep 5
83}
84
85stop_sched() {
86        start-stop-daemon --retry 5 --stop --quiet --exec $TORQUE_DIR/pbs_sched
87        echo " pbs sched"
88}
89
90stop_mom() {
91        start-stop-daemon --retry 5 --stop --quiet --exec $TORQUE_DIR/pbs_mom
92        echo " pbs mom"
93}
94
95stop_daemons() {
96        if [ "$PBS_SERVER" = "1" ]
97        then
98                stop_server
99        fi
100
101        if [ "$PBS_SCHED" = "1" ]
102        then
103                stop_sched
104        fi
105
106        if [ "$PBS_MOM" = "1" ]
107        then
108                stop_mom
109        fi
110}
111
112
113## Check permissions and directories
114check_perms() {
115
116    check_dir() {
117        if [ ! -d "$1" ]; then
118            mkdir -m 1777 "$1"
119        else
120            chmod 1777 "$1"
121        fi
122    }
123
124    check_dir $SPOOLDIR/spool
125    check_dir $SPOOLDIR/undelivered
126}
127
128
129## Main
130case "$1" in
131        start)
132                echo "Starting $DESC: "
133                start_daemons
134        ;;
135
136        stop)
137                echo "Stopping $DESC: "
138                stop_daemons
139        ;;
140
141        restart)
142                echo "Restarting $DESC: "
143                stop_daemons
144                sleep 1
145                start_daemons
146        ;;
147
148        restart-mom)
149                echo "Restarting pbs_mom: "
150                                stop_mom
151                sleep 1
152                                start_mom
153        ;;
154
155        restart-sched)
156                echo "Restarting pbs_sched: "
157                                stop_sched
158                sleep 1
159                                start_sched
160        ;;
161
162
163        restart-server)
164                echo "Restarting pbs_server: "
165                                stop_server
166                sleep 1
167                                start_server
168        ;;
169
170        *)
171                echo "Usage: $0 {restart|start|stop|restart-mom|restart-server|restart-sched}\n" >&2
172                exit 1
173        ;;
174esac
175
176exit 0
Note: See TracBrowser for help on using the repository browser.