summaryrefslogtreecommitdiff
path: root/sysutils/torque/files/torque-config.in
blob: 40efbc7a50514e194bdd8640374bf4e5f9f1a147 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/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