Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | #!/bin/sh |
2 | ||
3 | tool=$0 | |
4 | ||
5 | usage() | |
6 | { | |
7 | echo "" | |
8 | echo "usage: `/bin/basename $tool` -i <nic> <installdir>" | |
9 | echo "" | |
10 | echo ' -i <nic> : specify the nic used.' | |
11 | echo "" | |
12 | echo " Get network veracity scripts: clientdump.ver,client.ver and server.ver with the specified nic and put them in <installdir>." | |
13 | echo " Before you use this, you should run "getstart" to generate start.ver which is included in the above files." | |
14 | echo "" | |
15 | } | |
16 | ||
17 | while getopts hi: OPT; do | |
18 | case $OPT in | |
19 | i) | |
20 | nic="$OPTARG" | |
21 | ;; | |
22 | h) | |
23 | usage | |
24 | exit 0 | |
25 | ;; | |
26 | *) | |
27 | usage | |
28 | exit 2 | |
29 | ;; | |
30 | esac | |
31 | done | |
32 | ||
33 | shift `/bin/expr $OPTIND - 1` | |
34 | ||
35 | if [ "$nic" = " " ]; then | |
36 | echo "Error: I need one -i argument." | |
37 | usage | |
38 | exit 2 | |
39 | fi | |
40 | ||
41 | installclientdump=$1/clientdump.ver | |
42 | installclient=$1/client.ver | |
43 | installserver=$1/server.ver | |
44 | ||
45 | for installfile in $installclientdump $installclient $installserver; | |
46 | do | |
47 | ||
48 | cat >$installfile <<EOF | |
49 | include "start.ver" | |
50 | ||
51 | timeout -1 | |
52 | ||
53 | expect | |
54 | set switchmachine [lindex \$argv 3] | |
55 | set serverport [lindex \$argv 4] | |
56 | EOF | |
57 | ||
58 | if [ $installfile = $installclientdump ]; then | |
59 | if [ $nic = "niu" ]; then | |
60 | cat >>$installclientdump <<EOF | |
61 | set clientip0 [lindex \$argv 5] | |
62 | set clientip1 [lindex \$argv 6] | |
63 | end_expect | |
64 | ||
65 | EOF | |
66 | else | |
67 | cat >>$installclientdump <<EOF | |
68 | set clientip [lindex \$argv 5] | |
69 | end_expect | |
70 | ||
71 | EOF | |
72 | fi | |
73 | elif [ $installfile = $installclient ]; then | |
74 | cat >>$installclient <<EOF | |
75 | end_expect | |
76 | ||
77 | EOF | |
78 | else | |
79 | if [ $nic = "niu" ]; then | |
80 | cat >>$installserver <<EOF | |
81 | set serverip0 [lindex \$argv 5] | |
82 | set clientip0 [lindex \$argv 6] | |
83 | set serverip1 [lindex \$argv 7] | |
84 | set clientip1 [lindex \$argv 8] | |
85 | end_expect | |
86 | ||
87 | EOF | |
88 | else | |
89 | cat >>$installserver <<EOF | |
90 | set serverip [lindex \$argv 5] | |
91 | set clientip [lindex \$argv 6] | |
92 | end_expect | |
93 | ||
94 | EOF | |
95 | fi | |
96 | fi | |
97 | ||
98 | cat >>$installfile <<EOF | |
99 | #set prompt for guest console | |
100 | set_prompt GUEST '# ' | |
101 | ||
102 | #set prompt for SAM | |
103 | set_prompt SAM 'stop: |sam>>> ' | |
104 | ||
105 | #set error patterns | |
106 | error GUEST "\[Ee]rror|ERR|\[Pp]anic" | |
107 | ||
108 | EOF | |
109 | ||
110 | case $nic in | |
111 | ce) | |
112 | echo 'send_wait SAM "simce connect $switchmachine/$serverport"' >>$installfile | |
113 | ;; | |
114 | ge) | |
115 | echo 'send_wait SAM "simge connect $switchmachine/$serverport"' >>$installfile | |
116 | ;; | |
117 | niu) | |
118 | echo 'send_wait SAM "niu 0 connect $switchmachine/$serverport"' >>$installfile | |
119 | echo 'send_wait SAM "niu 1 connect $switchmachine/$serverport"' >>$installfile | |
120 | ;; | |
121 | *) | |
122 | usage | |
123 | exit 2 | |
124 | ;; | |
125 | esac | |
126 | done | |
127 | ||
128 | #generate the remaining part for clientdump.ver | |
129 | cat >>$installclientdump <<EOF | |
130 | ||
131 | send SAM "run" | |
132 | wait SAM 'run: ' | |
133 | ||
134 | #sleep for a while to wait GUEST. | |
135 | expect | |
136 | sleep 5 | |
137 | end_expect | |
138 | ||
139 | EOF | |
140 | ||
141 | if [ $nic = "niu" ]; then | |
142 | cat >>$installclientdump <<EOF | |
143 | #execute commands. | |
144 | send_wait GUEST "/ll/cwd/sam.client \$clientip0 nxge0" | |
145 | send_wait GUEST "/ll/cwd/sam.client \$clientip1 nxge1" | |
146 | EOF | |
147 | else | |
148 | cat >>$installclientdump <<EOF | |
149 | #execute commands. | |
150 | send_wait GUEST "/ll/cwd/sam.client \$clientip" | |
151 | EOF | |
152 | fi | |
153 | ||
154 | cat >>$installclientdump <<EOF | |
155 | send_wait SAM "stop" | |
156 | send_wait SAM "dump client.dump" | |
157 | send_fini SAM "quit" | |
158 | EOF | |
159 | ||
160 | #generate the remaining part for client.ver | |
161 | cat >>$installclient <<EOF | |
162 | ||
163 | #execute commands. | |
164 | send_wait SAM "stepi 900000000000" | |
165 | send_fini SAM "quit" | |
166 | EOF | |
167 | ||
168 | #generate the remaining part for server.ver | |
169 | cat >>$installserver <<EOF | |
170 | ||
171 | #execute commands. | |
172 | send SAM "run" | |
173 | wait SAM 'run: ' | |
174 | ||
175 | #sleep for a while to wait GUEST. | |
176 | expect | |
177 | sleep 5 | |
178 | end_expect | |
179 | ||
180 | EOF | |
181 | ||
182 | if [ $nic = "niu" ]; then | |
183 | cat >>$installserver <<EOF | |
184 | send_wait GUEST "/ll/cwd/sam.server -s \$serverip0 -c \$clientip1 -i nxge0" | |
185 | send_wait GUEST "/ll/cwd/sam.server -s \$serverip1 -c \$clientip0 -i nxge1" | |
186 | EOF | |
187 | else | |
188 | cat >>$installserver <<EOF | |
189 | send_wait GUEST "/ll/cwd/sam.server -s \$serverip -c \$clientip" | |
190 | EOF | |
191 | fi | |
192 | ||
193 | cat >>$installserver <<EOF | |
194 | send_fini SAM "quit" | |
195 | EOF |