summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/LinHES-config-svn/install_proxy.sh
blob: 32d01d77b49cc25e7e7bdee5cf34b5f722c6a573 (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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
#!/bin/bash
#chroot  and /tmp
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"

#TEMPNET="Hostip"$default_interface
#eval MYTHIP=\$${TEMPNET}
function create_chroot_mnt_points() {

    echo "Creating directory for media in chroot"
    mkdir -p $mountpoint/media/cdrom
    mkdir -p $mountpoint/media/dvd
    mkdir -p $mountpoint/mnt

}
function cp_and_log () {
    ls $1 >/dev/null 2>&1
    status=$?
    if [ $status = 0 ]
    then
        echo "copying $1 to $2"
        cp -rfp $1 $2
    else
        echo "$1 is not present, skipping..."
    fi

}

function mdadm_find () {

    PREFIX=$1
    if [ -e $PREFIX/etc/KnoppMyth-version ]
    then
        MDADM_CONF="/etc/mdadm/mdadm.conf"
    else
        MDADM_CONF="/etc/mdadm.conf"
    fi
    echo "Using $MDADM_CONF"
}

progress () {
mypercent=`echo "$1" | cut -d. -f1`
if [  x$mypercent = x ]
then
echo "" > /tmp/.install_percent
else
echo "${mypercent}% complete" > /tmp/.install_percent
fi


}

function apply_new_auth () {
#check if file is present
    if  [ -f  /root/myth_user_call.out ]
    then
        #read in file, running each command in chroot
        exec 4</root/myth_user_call.out
        while read LINE <&4
        do
            if [ ! x"$LINE" = x ]
            then
                #run commands in chroot
                chroot "$mountpoint"   $MV_ROOT/bin/myth_user_call -i $LINE > /tmp/user_auth.update
            fi
        done
        rm -f /root/myth_user_call.out
    else
        echo "No new password changes to apply"
    fi
}


function backup_sql_check {
    if [ -f ${mountpoint}${BACKUPFILE} ]
    then
        echo "found ${mountpoint}${BACKUPFILE} "
        rc=0
    else
        echo "did not find ${mountpoint}${BACKUPFILE} "
        rc=1
    fi
    return $rc
}

function mdadm_assemble_all {

        mdadm_find /tmp
        mdadm --assemble --scan -c /tmp${MDADM_CONF}
        MDLIST=`grep ARRAY /tmp${MDADM_CONF}|tr -s [:space:]|cut -d" " -f2`
        for array in $MDLIST
        do
            echo "assembling array $array"
            mdadm --assemble -c /tmp${MDADM_CONF} $array
            sleep 2
            fsck -p $array
        done

}

function upgrade_mount_search {

    MYTH_P=`cat /tmp/etc/fstab |grep -E /myth[[:space:]] | awk ' {print $1 '} `
    umount $mountpoint/myth

    #should probably just mdadm all the time
    echo $MYTH_P |grep -q \/md.
    if [ $? = 0 ]
    then
        mdadm_assemble_all
    fi

    echo $MYTH_P |grep -q UUID
    if [ $? = 0 ]
    then
        MUUID=`echo $MYTH_P|cut -d= -f2|tr -d \"`
        echo blkid $MUUID
        blkid -t UUID=$MUUID
        if [ ! $? = 0 ]
        then
            echo "couldn't find $MUUID, starting md support"
            mdadm_assemble_all
        fi
        mount -U $MUUID $mountpoint/myth
        echo mount -U    $MUUID $mountpoint/myth
        MYTHMOUNT=`blkid -t UUID=$MUUID|cut -d: -f1`
        MYTHMOUNT=`basename $MYTHMOUNT`
        echo "MYTHMOUNT is $MYTHMOUNT"
    else
        mount $MYTH_P $mountpoint/myth
        echo mount $MYTH_P $mountpoint/myth
        MYTHMOUNT=`basename $MYTH_P`
        echo "MYTHMOUNT is $MYTHMOUNT"
    fi
    sleep 2
    backup_sql_check
    if [ $? = 1  ]
    then
        mkdir -p /new_boot/root/backup
        if [ ! -e /tmp/mythconverg.sql.gz ]
        then
            echo "Couldn't find ANY database to restore, upgrade will continue but a new database will be installed."
        else
            cp_and_log  /tmp/mythconverg.sql.gz  /new_boot/root/backup/mythconverg.sql.gz
            BACKUPFILE="/root/backup/mythconverg.sql.gz"
            echo "setting BACKUPFILE to $BACKUPFILE"
        fi
    fi
    return 0
}


full_install () {
    if [ -f /tmp/.this_is_upgrade ]
    then
        rm /tmp/.this_is_upgrade
    fi
    echo "Partitioning $disk" > /tmp/.install_state
    progress 1
    sleep 1
    $run partition_it $disk $rootsize $datasize $swapsize

    echo "Formatting $disk" > /tmp/.install_state
        progress 2
    sleep 1
    $run format_it $disk $rootfs $datafs

    echo "Preparing $disk" > /tmp/.install_state
    progress 3
    sleep 1
    $run mount_it $disk

    startsize=`statgrab -M disk.|grep $disk.write_bytes|cut -d= -f 2|tr -d " "`

    echo "STARTSIZE=$startsize">/tmp/.startsize.io
    echo "Creating $hostname" > /tmp/.install_state

    sleep 1
        $run copy_it $disk ALL
        rm $mountpoint/etc/fstab
        $run fstab_fix_it $disk $rootfs $datafs FULL_INSTALL
        echo "Configuring system" > /tmp/.install_state
        progress 100
    #progress 99
    sleep 1
    $run grub_it $disk


        #echo "Configuring system" > /tmp/.install_state
        #progress 100
        sleep 1
        cp_and_log  /etc/systemconfig "$mountpoint"/etc
        cp_and_log /root/xorg.conf.install "$mountpoint"/etc/X11/xorg.conf.install
        #run save syssettings to save settings, then copy to new mountpoint
        $MV_ROOT/bin/restore_default_settings.sh  -c save -t syssettings -h $MVHOSTNAME -d localhost
        SE=$TEMPLATES/settings/syssettings
        mkdir -p ${mountpoint}$SE
        #cp -rp  $SE/*  ${mountpoint}$SE/
        cp_and_log "$SE/*"  "${mountpoint}$SE/"
        chown root:mythtv "$mountpoint"/etc/systemconfig
        chown -R mythtv:mythtv ${mountpoint}$SE

        chmod -R 775   ${mountpoint}$SE
        chmod 775 "$mountpoint"/etc/systemconfig
        mkdir -p "$mountpoint"/var/log/mythtv
        chown mythtv "$mountpoint"/var/log/mythtv
        #copy over any updates that might have occured
        #cp -rp   $MV_ROOT/bin/*.sh "$mountpoint"$MV_ROOT/bin/
        cp_and_log   "$MV_ROOT/bin/*.sh" "$mountpoint"$MV_ROOT/bin/
        chmod -R 755 ${mountpoint}/root
        create_chroot_mnt_points
        cp_and_log /etc/mtab "$mountpoint"/etc/mtab
     #   cp_and_log /etc/hostname "$mountpoint"/etc/hostname
        apply_new_auth


    if  [ $SystemType = "Master_backend" -o $SystemType = "Standalone"  ]
    then
            #installing DB to local machine
            #turn off old live database, so the chroot one can start
            echo "---------------------CHROOT INSTALLDB-------------------------"
            /etc/rc.d/mysqld stop
            mount --bind /dev "$mountpoint/dev"
            mount --bind /proc "$mountpoint/proc"
            chroot "$mountpoint"   "$MV_ROOT/bin/install_db_chroot.sh" 2>&1 |tee /tmp/chrootdb.out
            #chroot "$mountpoint"   "$MV_ROOT/bin/install_db_chroot.sh"
            chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh misc,hostype,network,advanced,this_is_install
            echo "stopping mysql in chroot"
            chroot "$mountpoint" /etc/rc.d/mysqld stop
            kill_dhcp_chroot
            sleep 2
            lsof |grep new_boot
            umount -l "$mountpoint/dev"
            umount -l "$mountpoint/proc"

            echo "---------------------END CHROOT INSTALLDB-------------------------"
            /etc/rc.d/mysqld start
    else
            #update remotedb with this host settings
            chroot "$mountpoint" DISPLAY=127.0.0.1:0  /usr/local/bin/MythVantage -t  restore,default_1
            chroot "$mountpoint" $MV_ROOT/bin/restore_default_settings.sh -c restore -t syssettings
            if [ !  $? = 0 ]
            then
                touch $mountpoint/tmp/.dbsysfailed
                chmod 777 $mountpoint/tmp/.dbsysfailed
            else
            #Run second time
            chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh misc,hostype,network,advanced,this_is_install
            chroot "$mountpoint" $MV_ROOT/bin/restore_default_settings.sh -c  ACCESSCONTROL
            fi
    fi
    chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh advanced
    touch $mountpoint/home/mythtv/.configure && chmod 777 $mountpoint/home/mythtv/.configure

    echo "Done" > /tmp/.install_state
    cp_and_log /tmp/mythvantage_install.log  $mountpoint/var/log/
    $run umount_it $disk

}

function createsquashlist(){
if [ -f $1 ]
then
    rm -f
$1
fi
for i in bin boot etc home lib opt root sbin usr var data
do
echo $i >> $1
done


}




function upgrade () {
    touch /tmp/.this_is_upgrade

    if [ ! x$rootfs = "xDo_not_format" ]
    then
        echo "Formatting $disk" > /tmp/.install_state
            progress 2
            sleep 1
            $run format_it $disk $rootfs NO
    fi
    echo "Preparing $disk" > /tmp/.install_state
        progress 3
        sleep 1
        $run mount_it $disk
        startsize=`statgrab -M disk.|grep $disk.write_bytes|cut -d= -f 2|tr -d " "`
        echo "STARTSIZE=$startsize">/tmp/.startsize.io
        echo "Upgrading $hostname" > /tmp/.install_state
        sleep 1
        cp_and_log  /tmp/etc /new_boot/etc.old
        cp_and_log   /tmp/oss /new_boot/var/lib/oss.old


        SQUASHLIST="/tmp/.squashlist"
        createsquashlist $SQUASHLIST
        $run copy_it $disk $SQUASHLIST
        #copy back ssh keys

#        cp_and_log -rp /data/var/cache/pacman/pkg/* /new_boot/data/var/cache/pacman/pkg/
        cp_and_log  "/new_boot/etc.old/ssh/*.pub"   /new_boot/etc/ssh/
        cp_and_log "/new_boot/etc.old/ssh/*.key"   /new_boot/etc/ssh/
        cp_and_log "/new_boot/etc.old/ssh/*key"  /new_boot/etc/ssh/
        mdadm_find /tmp
        cp_and_log /tmp${MDADM_CONF} /new_boot/etc
        #cp_and_log  /new_boot/etc.old/mdadm/mdadm.conf /new_boot/etc/
        cp_and_log /new_boot/etc.old/asound.state /new_boot/etc/
        if [ ! -f /tmp/etc/KnoppMyth-version ]
        then
            #passwd/shadow/group
            cp_and_log  /new_boot/etc.old/passwd /new_boot/etc/
            cp_and_log  /new_boot/etc.old/shadow /new_boot/etc/
            cp_and_log  /new_boot/etc.old/group   /new_boot/etc/
        fi
        mkdir -p "$mountpoint"/var/log/mythtv
        chown mythtv "$mountpoint"/var/log/mythtv
        if [  x$rootfs = "xDo_not_format" ]
        then
            rootfs=`grep \/\  /tmp/etc/fstab |awk ' { print $3 } '`
        fi
        #this is here to copy in the systemconfig file as soon as possible.
        cp_and_log  /etc/systemconfig "$mountpoint"/etc/systemconfig
        echo "Configuring system" > /tmp/.install_state
        progress 100
        backup_sql_check
        if [ $? = 1 ]
        then
            upgrade_mount_search
        fi
        echo $run fstab_fix_it $disk UPGRADE $MYTHMOUNT
        $run fstab_fix_it $disk UPGRADE $MYTHMOUNT
        create_chroot_mnt_points

        #echo "Writing boot sector" > /tmp/.install_state
        #progress 99
        sleep 1
        $run grub_it $disk
        #echo "Configuring system" > /tmp/.install_state
        #progress 100
        sleep 1
        cp_and_log /etc/mtab "$mountpoint"/etc/mtab
        cp_and_log  /etc/systemconfig "$mountpoint"/etc
        cp_and_log /root/xorg.conf.install "$mountpoint"/etc/X11/xorg.conf.install
#make sure mythconverg.sql.gz is present
        #backup_sql_check
        #if [ $? = 1 ]
        #then
        #    upgrade_mount_search
        #fi
        echo $CMDLINE | grep -q clean_upgrade
        status=$?
        if [  -f /tmp/etc/KnoppMyth-version -o  $status = 0 ]
        then
            #run save syssettings to save settings, then copy to new mountpoint
            $MV_ROOT/bin/restore_default_settings.sh  -c save -t syssettings -h $MVHOSTNAME -d localhost
            SE=$TEMPLATES/settings/syssettings
            mkdir -p ${mountpoint}$SE
            #cp -rfp  $SE/*  ${mountpoint}$SE/
            cp_and_log "$SE/*"  "${mountpoint}$SE/"
            chown root:mythtv "$mountpoint"/etc/systemconfig
            chown -R mythtv:mythtv ${mountpoint}$SE
            chmod -R 775   ${mountpoint}$SE
            if [ ! $status = 0 ]
            then
                touch $mountpoint/home/mythtv/.kmupgrade && chmod 777 $mountpoint/home/mythtv/.kmupgrade
            fi
        fi



        cp_and_log  "$MV_ROOT/bin/*.sh" "$mountpoint"$MV_ROOT/bin/
        chmod -R 755 ${mountpoint}/root
        chown root:mythtv "$mountpoint"/etc/systemconfig
        chmod 775 "$mountpoint"/etc/systemconfig
        #mount /proc and /dev
         mount --bind /dev "$mountpoint/dev"
         mount --bind /proc "$mountpoint/proc"

        chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh misc,hostype,network,advanced,this_is_install
        #wrap this in a network check_network, no need to update the db if the import worked.
        #####  do I need to start mysql?
        /etc/rc.d/mysqld stop
        if  [ $SystemType = "Master_backend" -o $SystemType = "Standalone"  ]
        then
            echo $CMDLINE | grep -q clean_upgrade
            status=$?
            if [ $status = 0 ]
            then
            #new db as part of clean upgrade
                echo "--------------------------------"
                echo "clean upgrade installing new database"
                echo "--------------------------------"
                chroot "$mountpoint"   "$MV_ROOT/bin/install_db_chroot.sh"  |tee /tmp/chrootdb.out
                echo "############################################"
                echo "End Installing new database/clean"
                echo "############################################"
            else
            #proceed as normal
                if [ -f "$mountpoint"/$BACKUPFILE ]
                then
                    echo "--------------------------------"
                    echo "Restoring database with $BACKUPFILE"
                    echo "--------------------------------"
                    chroot "$mountpoint"   "$MV_ROOT/bin/restore_km_db_chroot.sh" "$BACKUPFILE"  |tee   /tmp/chrootdb_km.out
                    echo "############################################"
                    echo "End Restoring database"
                    echo "############################################"
                else
                    echo "--------------------------------"
                    echo "Couldn't find backup file, installing new database"
                    echo "--------------------------------"
                    touch /tmp/.upgrade_db_failed
                    chroot "$mountpoint"   "$MV_ROOT/bin/install_db_chroot.sh"  |tee  /tmp/chrootdb.out
                    echo "############################################"
                    echo "End Installing new database"
                    echo "############################################"
                fi
            fi
        fi

        if [  -f /tmp/etc/KnoppMyth-version ]
        then
           chroot "$mountpoint" $MV_ROOT/bin/restore_default_settings.sh -c restore -t hostsettings
        #change permissions of /myth (only needed on km->linhes)
           chown -R mythtv:mythtv $mountpoint/myth
           chown -R root:root $mountpoint/myth/backup
        else
           chroot "$mountpoint" $MV_ROOT/bin/restore_default_settings.sh -c restore -t syssettings
        fi
        #
        #Run second time
        chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh misc,hostype,network,advanced,this_is_install
        chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh advanced,this_is_install
        echo "stopping mysql in chroot"
        chroot "$mountpoint" /etc/rc.d/mysqld stop
        apply_new_auth
        kill_dhcp_chroot
        umount -l "$mountpoint/dev"
        umount -l "$mountpoint/proc"

    echo "Done" > /tmp/.install_state
    cp_and_log /tmp/mythvantage_install.log  $mountpoint/var/log/

    $run umount_it $disk
    /etc/rc.d/mysqld start
}

function netboot-full_install () {
    TEMPVAR=${CMDLINE#*nfsroot=}
    NFSROOT=${TEMPVAR%% *}
    NFSROOT=`echo $NFSROOT|cut -d: -f1`
    MAC=`/sbin/ifconfig eth0|grep HWaddr| cut -d: -f2-|awk '{ print $3}'|tr : -`
    URL="http://$NFSROOT:1337/diskless.py?HOSTNAME=$hostname&MAC=$MAC"
    echo "calling $URL"
    echo "Starting" > /tmp/.install_state
    curl $URL
    ${MV_ROOT}/bin/xconfig.sh
}

# function killdhcp () {
# if [ -f /etc/dhcpc/dhcpcd-eth0.pid ]
#         then
#             pid=`cat /etc/dhcpc/dhcpcd-eth0.pid`
#             kill -9 $pid
#             rm -f /etc/dhcpc/dhcpcd-eth0.pid
#             rm -f /var/run/dhcpcd*
#         fi
# if [ -f /var/run/dhcpcd-eth0.pid ]
#         then
#             pid=`cat /var/run/dhcpcd-eth0.pid`
#             kill -9 $pid
#             rm -f /var/run/dhcpcd-eth0.pid*
#         fi
# ip address flush dev eth0
# }



function SANE_SYSETTINGS () {
sed -e '/HOSTrootfstype/d' \
        -e '/HOSTrootfstype/d' \
        -e '/HOSTdatafstype/d' \
        -e '/HOSTOSsize/d'  \
        -e '/HostUseALLdata/d'  \
        -e '/HOSTDATAsize/d'    \
        -e '/HOSTuprootfstype/d'    \
        -e '/HostUseSWAP/d' \
        -e '/HOSTSWAPsize/d  ' /tmp/templates/settings/syssettings/settings.txt  >  /tmp/settings.new
    mv  /tmp/settings.new /tmp/templates/settings/syssettings/settings.txt
}

case $1 in
        full_install_it )         full_install       ;;

        NETBOOT)
echo "-----------------------------------------------------------------------3-----"
         netboot-full_install   ;;

        find_update)

            #TRY TO mount first partition of drive
            #copy /etc/systemconfig to live,  import settings into db
            #umount drive
            echo $CMDLINE | grep -q clean_upgrade
            if [ $? = 1 ]
            then
                $run mount_it $disk
                [ -e "/new_boot/root/backup/mythconverg.sql.gz" ] && cp /new_boot/root/backup/mythconverg.sql.gz /tmp


                if [ -f /new_boot/etc/systemconfig ]
                then
                ###########ADD templates
                    mkdir -p $TEMP_TEMPLATES
                    cp_and_log  /new_boot/$TEMPLATES  $TEMP_TEMPLATES
                    SANE_SYSETTINGS
                    cp_and_log  $TEMP_TEMPLATES/settings $TEMPLATES/
                    cp_and_log /new_boot/etc/systemconfig /etc/systemconfig
                    cp_and_log   /new_boot/etc /tmp/etc
                    cp_and_log  /new_boot/var/lib/oss  /tmp/oss
                    [ -e /tmp/etc/mdadm.conf ] && cp_and_log  /tmp/etc/mdadm.conf /etc/

                    $MV_ROOT/bin/restore_default_settings.sh -c restore -t syssettings -h $MVHOSTNAME  -d 127.0.0.1
                else
                    cp_and_log   /new_boot/etc /tmp/etc
                    [ -e /tmp/etc/mdadm.conf ] && cp_and_log  /tmp/etc/mdadm.conf /etc/
                    #now we search for the timezone and try to update
                    TZREGION=`cat /tmp/etc/timezone | cut -d"/" -f1`
                    TZSUB=`cat /tmp/etc/timezone | cut -d"/" -f2 -`


                    if [  $TZREGION = $TZSUB ]
                    then
                            $run update_db_it  HostTimeZoneRegion "$TZREGION"
                    else
                            $run update_db_it  HostTimeZoneRegion "$TZREGION"
                            $run update_db_it  HostTimeZoneRegion_$TZREGION "$TZSUB"
                    fi
                fi
                backup_sql_check
                echo $?
                upgrade_mount_search
                echo $?
                $run umount_it $disk
            fi
            ;;

        upgrade_it)
                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`
                                            status=$?
                                            #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"
                                                    status=0
                                                else
                                                    echo "IP in DNS but doesn't match mine, hostname is not safe to use"
                                                    status=7
                                                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
            cond3=$(echo "$percent < 3" |bc )
            if [ $cond3 -eq 0   ]
                then
                    progress $percent
                fi
            fi
        fi
        ;;
esac