GCCluster: redhat.pbs_server

File redhat.pbs_server, 2.3 KB (added by Pieter Neerincx, 12 years ago)

/etc/init.d/ script for pbs_server (Redhat/CentOS/Fedora flavor)

Line 
1#!/bin/sh
2#
3# pbs_server    This script will start and stop the PBS Server
4#
5# chkconfig: 345 95 5
6# description: PBS is a versatile batch system for SMPs and clusters
7#
8# Source the library functions
9. /etc/rc.d/init.d/functions
10
11PBS_DAEMON=/usr/local/sbin/pbs_server
12PBS_HOME=/var/spool/torque
13PBS_ARGS=""
14PBS_SERVERDB="$PBS_HOME/server_priv/serverdb"
15export PBS_DAEMON PBS_HOME PBS_ARGS PBS_SERVERDB
16
17create() {
18    echo -n "Creating initial TORQUE configuration: "
19    if [ -r $PBS_SERVERDB ]; then
20        echo "Configuration already exists.  Please remove $PBS_SERVERDB to create a new one."
21        exit 1
22    fi
23
24    $PBS_DAEMON -d $PBS_HOME -t create &
25    while [ ! -r $PBS_SERVERDB ]; do
26        sleep 1
27    done
28    killproc pbs_server
29    RET=$?
30}
31
32start() {
33    status pbs_server >/dev/null 2>&1
34    if [ $? -eq 0 ]; then
35        echo "pbs_server is already running."
36        exit 0
37    fi
38    echo $PBS_SERVERDB
39    if [ ! -r $PBS_SERVERDB ]; then
40                #
41                # Commented out automagic create: this is dangerous and will blow
42        # away the serverdb file if $TORQUE_HOME isn't the default...
43                #
44        #create
45        echo "serverdb not initialized or not in the expected location."
46        echo "If this is a new installation you create the serverdb with: service pbs_server create."
47        echo "Else you should already have a serverdb and you will want to check your setup."
48        exit 0
49    fi
50    echo -n "Starting TORQUE Server: "
51    daemon $PBS_DAEMON -d $PBS_HOME $PBS_ARGS
52    RET=$?
53    [ $RET -eq 0 ] && touch /var/lock/subsys/pbs_server
54    echo
55}
56
57stop() {
58    status pbs_server >/dev/null 2>&1
59    if [ $? -ne 0 ]; then
60        echo "pbs_server is not running."
61        exit 0
62    fi
63    echo -n "Shutting down TORQUE Server: "
64    killproc pbs_server
65    RET=$?
66    rm -f /var/lock/subsys/pbs_server
67    echo
68}
69
70reload() {
71    echo -n "Reloading pbs_server: "
72    killproc pbs_server -HUP
73    RET=$?
74    echo
75}
76
77if [ -f /etc/sysconfig/pbs_server ]; then
78   . /etc/sysconfig/pbs_server
79fi
80
81# let see how we were called
82case "$1" in
83        start)
84                start
85                ;;
86        stop)
87                stop
88                ;;
89        status)
90                status pbs_server
91                RET=$?
92                ;;
93        restart)
94                stop
95                start
96                ;;
97        reload)
98                reload
99                ;;
100        create)
101                create
102                ;;
103        *)
104                echo "Usage: pbs_server {start|stop|restart|status|reload|create}"
105                exit 1
106esac
107exit $RET