forked from XIA-Project/GENI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xbuild
executable file
·82 lines (72 loc) · 1.71 KB
/
xbuild
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh
#
# Slaspdash script for creating an XIA tutorial network on GENI.
#
if [ `uname` == "Darwin" ]; then
rtl="/Applications/omniTools-2.9/readyToLogin.app/Contents/MacOS/readyToLogin"
omni="/Applications/omniTools-2.9/omni.app/Contents/MacOS/omni --error "
else
rtl="readytoLogin"
omni="omni --error "
fi
if [ $# != 2 ]; then
echo usage: xbuild slicename aggregate
echo use: omni nicknames to find valid aggregate names
exit
fi
T="$(date +%s)"
found=`$omni --info listslices 2>&1 > /dev/null | grep $1`
if [ "$found" == "" ]; then
echo creating slice $1
$omni createslice $1
[ $? -ne 0 ] && exit
else
echo using existing slice $1
fi
echo creating sliver in $1
$omni createsliver -a $2 $1 xiatutorial.rspec
[ $? -ne 0 ] && exit
echo waiting for sliver to be ready
numready=0
dots=1
while true; do
numready=`$rtl -a $2 $1 | grep "is: ready" | wc -l | tr -s " " | cut -d " " -f 2`
if [ $numready -eq 5 ]; then
break
elif [ $numready -gt 0 ]; then
if [ $dots -eq 1 ]; then
dots=0
printf "\n"
fi
echo "$numready node(s) are in the ready state"
sleep 15
else
printf "."
sleep 5
printf "."
sleep 5
printf "."
sleep 5
fi
done
T="$(($(date +%s)-T))"
printf "Imaging %s on %s took %02d:%02d\n" $1 $2 "$((T/60))" "$((T%60))"
$rtl -a $2 $1 -o >/dev/null
read -p "Backup and replace ~/.ssh/config? (yn) " x
copy=0
if [ "$x" == "y" ]; then
if [ -e ~/.ssh/config.save ]; then
read -p "~/.ssh/config.save already exists. Overwrite? (yn) " x
if [ "$x" == "y" ]; then
copy=1
fi
else
copy=1
fi
fi
if [ $copy -eq 1 ]; then
cp ~/.ssh/config ~/.ssh/config.save
cp sshconfig.txt ~/.ssh/config
else
echo "~/.ssh/config not overwritten. The new ssh config settings can be found in sshconfig.txt"
fi