1 | #!/bin/sh |
---|
2 | |
---|
3 | # find perl |
---|
4 | if [ -x "/usr/bin/perl" ]; then |
---|
5 | PERL="/usr/bin/perl" |
---|
6 | else |
---|
7 | if [ -x "/usr/local/bin/perl" ]; then |
---|
8 | PERL="/usr/local/bin/perl" |
---|
9 | else |
---|
10 | # Wing it... |
---|
11 | PERL="perl" |
---|
12 | fi |
---|
13 | fi |
---|
14 | |
---|
15 | # Find this experiment's stashed scripts. (Perl for advanced parsing) |
---|
16 | EMUDIR="/usr/local/etc/emulab/" |
---|
17 | PROJECT=`$EMUDIR/tmcc -b status | $PERL -ne '/ALLOCATED=([^\/]+)\/([^\s]+)/ && print "$1\n";'` |
---|
18 | EXP=`$EMUDIR/tmcc -b status | $PERL -ne '/ALLOCATED=([^\/]+)\/([^\s]+)/ && print "$2\n";'` |
---|
19 | CONFIGDIR="/proj/$PROJECT/exp/$EXP/tmp" |
---|
20 | SCRIPTDIR="/usr/local/federation/bin" |
---|
21 | |
---|
22 | # Very simple script to copy the global hosts file over the local one |
---|
23 | # while preserving the localhost entry. Run on DETER master clients |
---|
24 | |
---|
25 | grep 127\\.0\\.0\\.1 /etc/hosts > /tmp/hosts |
---|
26 | cat "$CONFIGDIR/hosts" >> /tmp/hosts |
---|
27 | cp /tmp/hosts /etc/hosts && rm /tmp/hosts |
---|
28 | |
---|
29 | # Find the right version of pkill. For killing. |
---|
30 | if [ -x "/usr/bin/pkill" ] ; then |
---|
31 | PKILL="/usr/bin/pkill" |
---|
32 | else |
---|
33 | if [ -x "/bin/pkill" ] ; then |
---|
34 | PKILL="/bin/pkill" |
---|
35 | else |
---|
36 | PKILL="echo" |
---|
37 | fi |
---|
38 | fi |
---|
39 | |
---|
40 | # XXX: modified seer daemon to read a config file. Not in the tarfile yet. If |
---|
41 | # we see one, and there's a /usr/seer/backend/daemon.py, replace that one with |
---|
42 | # the local one. |
---|
43 | if [ -e /usr/seer/backend/daemon.py ] && [ -e $SCRIPTDIR/daemon.py ]; then |
---|
44 | /bin/cp $SCRIPTDIR/daemon.py /usr/seer/backend/daemon.py |
---|
45 | fi |
---|
46 | |
---|
47 | if [ -e /usr/seer/backend/experiment-setup.py ] && [ -e $SCRIPTDIR/experiment-setup.py ]; then |
---|
48 | /bin/cp $SCRIPTDIR/experiment-setup.py /usr/seer/backend/experiment-setup.py |
---|
49 | fi |
---|
50 | |
---|
51 | # Copy the seer.conf to the local /tmp if there is one |
---|
52 | |
---|
53 | if [ -e $CONFIGDIR/seer.conf ]; then |
---|
54 | /bin/cp $CONFIGDIR/seer.conf /tmp |
---|
55 | fi |
---|
56 | |
---|
57 | |
---|
58 | # SEER feels pain and confusion if times are wrong. This lays a big lick on |
---|
59 | # ntp sets the time directly and then restarts it. XXX FreeBSD incantation is |
---|
60 | # untested. |
---|
61 | |
---|
62 | case `uname` in |
---|
63 | "FreeBSD") |
---|
64 | /etc/rc.d/ntpd stop |
---|
65 | /usr/sbin/ntpdate boss |
---|
66 | /etc/rc.d/ntpd start |
---|
67 | ;; |
---|
68 | "Linux") |
---|
69 | /etc/rc.d/init.d/ntpd stop |
---|
70 | /usr/sbin/ntpdate boss |
---|
71 | /etc/rc.d/init.d/ntpd start |
---|
72 | ;; |
---|
73 | esac |
---|
74 | |
---|
75 | # If we need to configure an interface up for a DRAGON embedding, do it here. |
---|
76 | if [ -e $SCRIPTDIR/config_from_tunnelip.pl ]; then |
---|
77 | $PERL $SCRIPTDIR/config_from_tunnelip.pl |
---|
78 | fi |
---|
79 | # I remain unclear why ospfd seems screwed up after the resetting of accounts |
---|
80 | # and mounts. This seems to fix it, but it's not very satisfying. At this |
---|
81 | # point the federated topology is complete, so any problems with routing in a |
---|
82 | # partial topology -e.g. failed or partial bridging - that might have confused |
---|
83 | # the router should be gone. |
---|
84 | $PKILL ospf |
---|
85 | $PKILL gated |
---|
86 | |
---|
87 | # XXX Danger, hack ahead. Apparently our FC6-SMB image and emulab disagree |
---|
88 | # about where gated lives. This will alias it. |
---|
89 | if [ ! -x /usr/sbin/gated ] ; then |
---|
90 | if [ -x /sbin/gated ] ; then |
---|
91 | ln /sbin/gated /usr/sbin/gated |
---|
92 | fi |
---|
93 | fi |
---|
94 | /usr/local/etc/emulab/rc/rc.route |
---|
95 | |
---|
96 | |
---|
97 | # Execute any command passed in as a startcmd. This basically daisy chains the |
---|
98 | # startcmd. This needs to become a perl script to have uniform behavior here. |
---|
99 | echo "*$1* *$2*" |
---|
100 | if [ ! -z "$1" ]; then |
---|
101 | echo "calling *$1* *$2*" |
---|
102 | case `uname` in |
---|
103 | "FreeBSD") |
---|
104 | su -l "$1" -c "$2" |
---|
105 | ;; |
---|
106 | "Linux") |
---|
107 | su "$1" --command="$2" |
---|
108 | ;; |
---|
109 | esac |
---|
110 | fi |
---|