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