summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-config/restore_km_db_chroot.sh
blob: 170dd9ecfb22d15d573ad25856338bf78b8f885a (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
#!/bin/bash
. /etc/profile
. /etc/systemconfig
. $MV_ROOT/bin/install_functions.sh

myhost=$hostname
hostname $myhost
mount -t proc none /proc
DBFILE=$1

if  [ $SystemType = "Master_backend" -o $SystemType = "Standalone"  ]
    then
        #restore database
        pacman --noconfirm -S mysql
        status=1
        mysqlstatus=1
        while [ ! $status = 0  ]
        do
            /etc/rc.d/mysqld stop
            sleep 1
            /etc/rc.d/mysqld start
            mysqlstatus=$?
            if [ $mysqlstatus = 0 ]
            then
                mysql -e "show databases;"
                showstatus=$?
                if [ $showstatus = 0 ]
                then
                   #load database
                   pacman --noconfirm -R mythdb-initial
                   pacman --noconfirm  -S mythdb-initial

                   if [ -f $DBFILE ]
                   then
                        echo "restoring old database"
                        gunzip -c $DBFILE > /tmp/mythconverg.sql
                        mysql  mythconverg < /tmp/mythconverg.sql
                        update_db_settings HostServiceMythWEB "1"
                        echo 'UseMythWEB="1"' >> /etc/systemconfig
                   else
                        echo "Could not restore old database, mythconverg.sql is missing."
                        touch /tmp/.upgrade_db_failed
                   fi

                    if [ -d /data/srv/mysql/mythconverg ]
                    then
                        status=0
                    fi
                fi
            fi
        done
        rm -f /tmp/mythconverg.sql
    else
        exit 0
    fi

#/etc/rc.d/mysqld stop
#umount /proc