source: branches/2.4/init.d @ 82

Last change on this file since 82 was 45, checked in by bas, 14 years ago

reverting back to old installation with one single package

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