#!/bin/sh -e usage() { printf "Usage: $0 head|compute\n" exit 1 } if [ $# != 1 ]; then usage fi node_type=$1 if [ $node_type != 'head' ] && [ $node_type != 'compute' ]; then usage fi spool_root=/var/spool if [ -e $spool_root/torque ]; then printf "$spool_root/torque already exists. Aborting...\n" exit 1 fi cp -Rp %%PREFIX%%/share/examples/torque/var/spool/torque $spool_root for dir in checkpoint spool undelivered; do chmod 1777 $spool_root/torque/$dir done cat << EOM =========================================================================== Enter the hostname of the torque server. This should be resolved by /etc/hosts on all nodes. A short hostname is preferred. =========================================================================== EOM read server_hostname echo $server_hostname > $spool_root/torque/server_name case $node_type in 'head') vi $spool_root/torque/server_priv/nodes if ! fgrep -q 'pbs_server_enable="YES"' /etc/rc.conf; then printf 'pbs_server_enable="YES"\n' >> /etc/rc.conf fi if ! fgrep -q 'pbs_sched_enable="YES"' /etc/rc.conf; then printf 'pbs_sched_enable="YES"\n' >> /etc/rc.conf fi %%PREFIX%%/share/examples/torque/torque.setup root %%PREFIX%%/etc/rc.d/pbs_server restart %%PREFIX%%/etc/rc.d/pbs_sched restart ;; 'compute') printf "Torque server IP address? " read server_ip printf '$pbsserver %s /var/spool/torque/mom_priv/config' $server_ip \ > $spool_root/torque/mom_priv/config if ! fgrep -q 'pbs_mom_enable="YES"' /etc/rc.conf; then printf 'pbs_mom_enable="YES"\n' >> /etc/rc.conf fi %%PREFIX%%/etc/rc.d/pbs_mom restart ;; esac