source: trunk/postinst @ 86

Last change on this file since 86 was 86, checked in by jaap, 7 years ago

Changed scripts to work with torque 5.0.1.

File size: 3.4 KB
Line 
1#!/bin/sh -e
2#
3# Authors: Bas van der Vlies & Jaap Dijkshoorn
4# Desc.  : Put a default torque file in /etc/default/torque
5#
6# SVN INFO:
7#       $Id: postinst 2329 2006-09-21 10:12:53Z bas $
8#set -x
9
10SPOOLDIR=/var/spool/torque
11SERVER_CONF_FILE=${SPOOLDIR}/server_name
12CONFIG_FILE=/etc/default/torque
13MKDIR="/usr/sbin/pbs_mkdirs"
14
15
16# Always check/create the directory structure
17#
18$MKDIR all
19
20
21# Source debconf library.
22. /usr/share/debconf/confmodule
23
24
25# Also build the tclindexes again for xpbs xpbsmon
26#
27for file in xpbs xpbsmon
28do
29        if [ -d  /usr/lib/torque/$file ] 
30        then
31                cd /usr/lib/torque/$file
32                ./buildindex /usr/lib/torque/$file
33        fi
34done
35
36
37# creating default file torque in /etc/default
38#
39create_default_torque_file() {
40    set_conf_options() {
41        RESULT=""
42        db_get torque/$1 || true
43        if [ $? -eq 0 ]; then
44            RESULT=$RET
45        fi
46    }
47
48    PBS_SERVER=0
49    PBS_MOM=0
50    PBS_SCHED=0
51    PBS_MOM_OPTS=""
52    PBS_MOM_RESTART_OPTS=""
53    PBS_SCHED_OPTS=""
54    PBS_SERVER_OPTS=""
55
56    db_get torque/daemon_list
57
58    for daemon in $RET; do
59        daemon=${daemon%,}
60
61        # this sets $RESULT
62        set_conf_options ${daemon}_opts
63
64        case "$daemon" in
65            pbs_server)
66                PBS_SERVER=1
67                PBS_SERVER_OPTS=$RESULT
68                ;;
69            pbs_mom)
70                PBS_MOM=1
71                PBS_MOM_OPTS=$RESULT
72
73                set_conf_options ${daemon}_restart_opts
74                PBS_MOM_RESTART_OPTS=$RESULT
75
76                ;;
77            pbs_sched)
78                PBS_SCHED=1
79                PBS_SCHED_OPTS=$RESULT
80                ;;
81        esac
82    done
83
84  cat > $CONFIG_FILE << EOF
85#
86# Author: Bas van der Vlies & Jaap Dijkshoorn
87# created with install of torque
88#
89# Do not edit this file by hand, use
90#
91#     dpkg-reconfigure -p high torque
92#
93# to change which daemons to start or
94#
95#     dpkg-reconfigure -p medium torque
96#
97# to even change startup options (PBS_{MOM,SCHED,SERVER}_OPTS).
98
99PBS_MOM=$PBS_MOM
100PBS_SCHED=$PBS_SCHED
101PBS_SERVER=$PBS_SERVER
102
103PBS_MOM_OPTS="$PBS_MOM_OPTS"
104PBS_MOM_RESTART_OPTS='$PBS_MOM_RESTART_OPTS'
105PBS_SCHED_OPTS="$PBS_SCHED_OPTS"
106PBS_SERVER_OPTS="$PBS_SERVER_OPTS"
107
108EOF
109}
110
111
112if [ "$1" = configure ]
113then
114        if [ ! -f $CONFIG_FILE ]
115        then
116                create_default_torque_file
117        fi
118fi
119
120
121#
122# Generate server_name
123#
124if [ "$1" = configure -o ! -f $SERVER_CONF_FILE ]; then
125
126    db_get torque/server_name || true
127    NEW_SERVER_NAME="$RET"
128    OLD_SERVER_NAME="`cat $SERVER_CONF_FILE`"
129
130#    if [ "$OLD_SERVER_NAME" != "$NEW_SERVER_NAME" ]; then
131#        # backup
132#        mv $SERVER_CONF_FILE $SERVER_CONF_FILE.`date +"%Y%m%d-%H%M%S"`
133#    fi
134
135    echo $NEW_SERVER_NAME > $SERVER_CONF_FILE
136fi
137
138
139#
140# make the spool directory an set mode bits.
141#
142if [ ! -d $SPOOLDIR/spool ]
143then
144        mkdir $SPOOLDIR/spool
145fi
146chmod 1777 $SPOOLDIR/spool
147chmod 1777 $SPOOLDIR/undelivered
148
149
150# pbs_sched needs a subdir not created by pbs_mkdirs.
151if [ ! -d $SPOOLDIR/sched_priv/accounting ]
152then
153    mkdir $SPOOLDIR/sched_priv/accounting
154fi
155
156#
157# create an empty config file for pbs_mom if missing
158#
159if [ ! -f $SPOOLDIR/mom_priv/config ]
160then
161    touch $SPOOLDIR/mom_priv/config
162fi
163
164
165#DEBHELPER#
166
167
168# Automatically added by dh_installinit
169if [ -x "/etc/init.d/torque" ]; then
170        update-rc.d torque defaults 99 1 >/dev/null
171        if [ -x "`which invoke-rc.d 2>/dev/null`" ]
172        then
173        if [ "$1" = configure ]
174                then
175                        invoke-rc.d torque restart || exit $? 
176                else
177                        invoke-rc.d torque start || exit $?
178        fi
179        fi
180fi
181# End automatically added section
182
183
Note: See TracBrowser for help on using the repository browser.