1 | #!/bin/bash
|
---|
2 | default_image="orbit-parallel"
|
---|
3 |
|
---|
4 | # Set up pxe links on repository2 for pxe boot
|
---|
5 |
|
---|
6 | nodeset=""
|
---|
7 | sub=`/sbin/ifconfig eth1 | grep 'inet addr' | cut -c21-26`
|
---|
8 | processLine_before(){
|
---|
9 | line="$@" # get all args
|
---|
10 | echo $line > node
|
---|
11 | node_x=`cut -f1 -d',' node`
|
---|
12 | node_y=`cut -f2 -d',' node`
|
---|
13 | node_id="node"$node_x"-"$node_y
|
---|
14 | subnet_ip=$sub$node_x"."$node_y
|
---|
15 | echo "My subnet number is $subnet_ip"
|
---|
16 | wget -O - "http://pxe:5012/pxe/setBootImage?img=$default_image&node=$node_id&ip=$subnet_ip"
|
---|
17 | # Reset the selected nodes using cmc service
|
---|
18 | wget -O - "http://cmc:5012/cmc/on?x=$node_x&y=$node_y"
|
---|
19 | wget -O - "http://cmc:5012/cmc/reset?x=$node_x&y=$node_y"
|
---|
20 | nodeset=$nodeset" "$node_id
|
---|
21 | }
|
---|
22 |
|
---|
23 | processLine_after(){
|
---|
24 | line="$@" # get all args
|
---|
25 | echo "$line" > node
|
---|
26 | node_x=`cut -f1 -d',' node`
|
---|
27 | node_y=`cut -f2 -d',' node`
|
---|
28 | node_id="node"$node_x"-"$node_y
|
---|
29 | subnet_ip=$sub$node_x"."$node_y
|
---|
30 | wget -O - "http://pxe:5012/pxe/clearBootImage?node=$node_id&ip=$subnet_ip"
|
---|
31 | wget -O - "http://cmc:5012/cmc/reset?x=$node_x&y=$node_y"
|
---|
32 | }
|
---|
33 | cp $1 /usr/$1
|
---|
34 | processLine_gexec(){
|
---|
35 | line="$@" # get all args
|
---|
36 | echo "$line" > node
|
---|
37 | node_x=`cut -f1 -d',' node`
|
---|
38 | node_y=`cut -f2 -d',' node`
|
---|
39 | node_id="node"$node_x"-"$node_y
|
---|
40 | export GEXEC_SVRS="$node_id"
|
---|
41 | subnet_ip=$sub$node_x"."$node_y
|
---|
42 | cd /usr
|
---|
43 | gexec -n 0 frisbee -p $port -m $multicast -i $subnet_ip /dev/hda &
|
---|
44 | }
|
---|
45 |
|
---|
46 |
|
---|
47 | FILE=""
|
---|
48 | # Make sure we get file name as command line argument
|
---|
49 | # Else read it from standard input device
|
---|
50 | if [ "$1" == "" ]; then
|
---|
51 | FILE="/dev/stdin"
|
---|
52 | else
|
---|
53 | FILE="$1"
|
---|
54 | # make sure file exist and readable
|
---|
55 | if [ ! -f $FILE ]; then
|
---|
56 | echo "$FILE : does not exists"
|
---|
57 | exit 1
|
---|
58 | elif [ ! -r $FILE ]; then
|
---|
59 | echo "$FILE: can not read"
|
---|
60 | exit 2
|
---|
61 | fi
|
---|
62 | fi
|
---|
63 | # read $FILE using the file descriptors
|
---|
64 | exec 3<&0
|
---|
65 | exec 0<$FILE
|
---|
66 | while read line
|
---|
67 | do
|
---|
68 | # use $line variable to process line in processLine() function
|
---|
69 | processLine_before $line
|
---|
70 | done
|
---|
71 | echo "$nodeset"
|
---|
72 | exec 0<&3
|
---|
73 |
|
---|
74 | sleep 120
|
---|
75 |
|
---|
76 | # Launch the frisbee server
|
---|
77 | export LD_ASSUME_KERNEL="2.4.2"
|
---|
78 | wget -O - "http://frisbee:5012/frisbee/getAddress?img=$2" > PORT
|
---|
79 |
|
---|
80 | port=`cut -c 11-15 PORT`
|
---|
81 | multicast=`cut -c 0-9 PORT`
|
---|
82 | FILE="$1"
|
---|
83 | exec 3<&0
|
---|
84 | exec 0<$FILE
|
---|
85 | while read line
|
---|
86 | do
|
---|
87 | #use $line variable to process line in processLine() function
|
---|
88 | processLine_gexec $line
|
---|
89 | done
|
---|
90 |
|
---|
91 | sleep 380
|
---|
92 |
|
---|
93 | #sleep 180
|
---|
94 | #export GEXEC_SVRS="$nodeset"
|
---|
95 | #export LD_ASSUME_KERNEL="2.4.2"
|
---|
96 | #cd /etc
|
---|
97 | #gexec -n 0 frisbee -p $port -m 224.0.0.2 -i $subnet_ip /dev/hda
|
---|
98 |
|
---|
99 | FILE="$1"
|
---|
100 | exec 3<&0
|
---|
101 | exec 0<$FILE
|
---|
102 | while read line
|
---|
103 | do
|
---|
104 | # use $line variable to process line in processLine() function
|
---|
105 | processLine_after $line
|
---|
106 | done
|
---|
107 |
|
---|
108 |
|
---|
109 | function usage()
|
---|
110 | {
|
---|
111 | echo "Usage: $0 {atheros|intel|all} image_file_path" >&2
|
---|
112 | echo "for example:" >&2
|
---|
113 | echo " $0 all tmp/image-tridencom-test.ndz" >&2
|
---|
114 | }
|
---|
115 | if [ $# -ne 2 ]
|
---|
116 | then
|
---|
117 | echo "ERROR: Wrong number of arguments: $1"
|
---|
118 | usage
|
---|
119 | exit 1
|
---|
120 | fi
|
---|