blob: 71b675bc985949e9885b3de3afd013288788a61f (
plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
#!/bin/bash
export TERM=vt100
MVHOSTNAME=larch5
. /etc/profile
TEMP_TEMPLATES=/tmp/templates
disk=$2
rootfs=$3
rootsize=$4
datafs=$5
datasize=$6
swapsize=$7
mountpoint="/new_boot"
run=$MV_ROOT/bin/install_functions.sh
. /etc/systemconfig 2>/dev/null
. $MV_ROOT/bin/networkconfig.sh
CMDLINE=$(cat /proc/cmdline)
BACKUPFILE="/myth/backup/mythconverg.sql.gz"
progress () {
mypercent=`echo "$1" | cut -d. -f1`
if [ x$mypercent = x ]
then
echo "" > /tmp/.install_percent
else
echo "${mypercent}% complete" > /tmp/.install_percent
fi
}
case $1 in
full_install_it )
mv_install.py --rootdisk=$disk --rootfs=$rootfs --rootsize=$rootsize --datafs=$datafs --datasize=$datasize --datadisk=$disk --swapsize=$swapsize -c full_install
rc=$?
echo "mv_install.py exit code $rc"
if [ $rc != 0 ]
then
echo "mv_install error" >> /tmp/.install_error
fi
exit $rc
;;
NETBOOT)
echo "-----------------------------------------------------------------------3-----"
netboot-full_install
;;
find_update)
mv_install.py --rootdisk=$disk -c find_upgrade
;;
upgrade_it)
mv_install.py --rootdisk=$disk --rootfs=$rootfs -c upgrade
;;
disk_model_it)
model="unknown"
size="xxx"
case $2 in
h* )
model=`cat /proc/ide/$2/model`
;;
s*) model=`sginfo /dev/$2|grep Product|awk ' { print $2 } '`
;;
esac
size=`parted /dev/$2 print |grep Disk|awk ' { print $3 } ' `
echo ""$model" $size " >/tmp/model
;;
network_check_it)
#Should never return from check_network
case $2 in
setup_network)
vnc_check
install_network_setup
;;
check_self)
myipdefault=`ifconfig | grep -C1 $default_interface| grep -v $default_interface | cut -d: -f2 | awk '{ print $1}'`
echo "network check myself"
ifconfig
ping -c 1 $myipdefault
if [ ! $? = 0 ]
then
exit 3
#can't ping yourself
fi
;;
check_gw)
#check gateway
echo "network check gateway"
/sbin/route -n
mygwdefault=`/sbin/route -n |grep $default_interface|grep UG|awk '{ print $2}'`
echo "Default gateway seems to be $mygwdefault"
if [ ! x$mygwdefault = x ]
then
sleep 2
ping -c 5 $mygwdefault
if [ ! $? = 0 ]
then
exit 4
fi
fi
;;
check_ns)
#check nameserver
echo " network check nameserver"
mydns=`cat /etc/resolv.conf|grep nameserver|head -1|awk '{ print $2}'`
ping -c 1 $mydns
if [ ! $? = 0 ]
then
exit 5
fi
;;
check_names)
echo "network check resolve names"
host google.com
if [ ! $? = 0 ]
then
exit 6
fi
;;
host_names)
#if host is found, then check to see if it's online
#if hoip matchs my ip assume it's ok
echo "network check my hostname $hostname"
hout=`host $hostname|head -n1`
status=$?
hoip=`echo $hout|awk '{print $4}'`
if [ $hoip = found: ]
then
status=1
fi
if [ $hoip = "out;" ]
then
#;; connection timed out; no servers could be reached
echo "DNS servers not found"
status=1
fi
unkownhost=`host unkown.linhes.org |head -n1 `
unkownhostip=`echo $unkownhost |awk '{print $4}'`
#found host, now grab the ip
if [ $status = 0 ]
then
hoip=`echo $hout|awk '{print $4}'`
/sbin/ifconfig -a |grep -q $hoip
if [ $? = 0 ]
then
echo "DNS ip matches on of my ips $hoip"
status=0
else
if [ $unkownhostip = $hoip ]
then
echo "Bad DNS returning false hits"
echo "Assuming hostname is OK"
echo "DNS unknown: $unkownhostip"
echo " HOSTDNS: $hoip "
/sbin/ifconfig -a |grep "inet addr"
else
echo "IP in DNS but doesn't match mine, hostname is not safe to use"
echo "DNS:$hoip"
echo "HOST: "
/sbin/ifconfig -a |grep "inet addr"
status=7
fi
fi
else
echo "Couldn't find hostname in DNS, must be safe to use"
status=0
fi
exit $status
;;
esac
exit 0
;;
* )
if [ -f /tmp/.install_state ]
then
state=`cat /tmp/.install_state`
else
state=" "
fi
if [ x"${state}" = "xConfiguring system" ]
then
progress ""
else
if [ -f /tmp/.startsize.io ]
then
. /tmp/.startsize.io
#finding the drive
ddrive=`df | grep $mountpoint | head -n1 | awk -F/ ' { print $3 } ' | cut -d" " -f 1|cut -b1,2,3 `
used=`statgrab -M disk.|grep ${ddrive}.write_bytes|cut -d= -f 2|tr -d " "`
used=`echo $used-$STARTSIZE|bc`
#echo $used
fi
if [ ! x$used = x ]
then
. /root/.install_size
#somehow find if it's an install or update
if [ -f /tmp/.this_is_upgrade ]
then
total=$UPGRADESIZE
else
total=$TOTALSIZE
fi
percent=`echo "scale=2 ; ($used/$total) * 100 " |bc `
cond2=$(echo "$percent > 98" |bc )
if [ $cond2 -eq 1 ]
then
percent=98
fi
if [ x"${state}" = "xDone" ]
then
percent=100
fi
cond3=$(echo "$percent < 3" |bc )
if [ $cond3 -eq 0 ]
then
progress $percent
fi
fi
fi
;;
esac
|