Subversion Repositories livecd

Rev

Rev 123 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 123 Rev 125
1
#!/bin/bash
1
#!/bin/bash
2
#
2
#
3
###############################################################
3
###############################################################
4
#
4
#
5
# Restore the system to a usable and bootable installation
5
# Restore the system to a usable and bootable installation
6
#
6
#
7
# Urs Beyerle, PSI
7
# Urs Beyerle, PSI
8
#
8
#
9
###############################################################
9
###############################################################
10
 
10
 
11
# source livecd.conf
-
 
12
. livecd.conf
-
 
13
 
-
 
14
###############################################################
-
 
15
 
-
 
16
function usage() {
11
function usage() {
17
 
12
 
18
   ## Usage
13
   ## Usage
19
   # ----------------------------------------------------------
14
   # ----------------------------------------------------------
20
 
15
 
21
   cat <<EOF
16
   cat <<EOF
22
 
17
 
23
   Options:
18
   Options:
24
 
19
 
25
    -h:       print this screen
20
    -h:       print this screen
26
    -psi:     customize for PSI Live CD
21
    -psi:     customize for PSI Live CD
27
 
22
 
28
EOF
23
EOF
29
 
24
 
30
}
25
}
31
 
26
 
32
###############################################################
27
###############################################################
33
 
28
 
34
### read options from command-line
29
### read options from command-line
35
PSI=""
30
PSI=""
36
while [ $# -gt 0 ]; do
31
while [ $# -gt 0 ]; do
37
 
32
 
38
    case "$1" in
33
    case "$1" in
39
       -h)
34
       -h)
40
            usage; exit;;
35
            usage; exit;;
41
       -psi)
36
       -psi)
42
            PSI=true; shift; continue;;
37
            PSI=true; shift; continue;;
43
       *)
38
       *)
44
            usage; exit;;
39
            usage; exit;;
45
    esac
40
    esac
46
 
41
 
47
done
42
done
48
 
43
 
49
 
-
 
50
###############################################################
-
 
51
 
-
 
52
### check if I run inside my directory
44
### check if I run inside my directory
53
if [ ! -x $( basename $0 ) ]; then
45
if [ ! -x $( basename $0 ) ]; then
54
    echo "Please run $( basename $0 ) within its directory"
46
    echo "Please run $( basename $0 ) within its directory"
55
    exit 1
47
    exit 1
56
fi
48
fi
57
 
49
 
-
 
50
# source livecd.conf
-
 
51
. livecd.conf
-
 
52
 
58
LIVECD_DIR=$( pwd )
53
LIVECD_DIR=$( pwd )
59
 
54
 
60
### restore /etc/rc.d/rc.sysinit
55
### restore /etc/rc.d/rc.sysinit
61
cp /etc/rc.d/rc.sysinit.ori /etc/rc.d/rc.sysinit
56
cp /etc/rc.d/rc.sysinit.ori /etc/rc.d/rc.sysinit
62
 
57
 
63
### enable ssh again
58
### enable ssh again
64
chkconfig sshd on 2>/dev/null
59
chkconfig sshd on 2>/dev/null
65
 
60
 
66
### create link to liblinuxlive
61
### create link to liblinuxlive
67
mkdir -p /livecd/live
62
mkdir -p /livecd/live
68
rm -f /livecd/live/liblinuxlive
63
rm -f /livecd/live/liblinuxlive
69
ln -s $LIVECD_DIR/linux-live.sl/initrd/liblinuxlive /livecd/live/liblinuxlive
64
ln -s $LIVECD_DIR/linux-live.sl/initrd/liblinuxlive /livecd/live/liblinuxlive
70
 
65
 
71
### restore /etc/resolv.conf
66
### restore /etc/resolv.conf
72
mv -f /etc/resolv.conf.ori /etc/resolv.conf
67
mv -f /etc/resolv.conf.ori /etc/resolv.conf
73
 
68
 
74
### move /etc/yum.repos.d, it will interfere with our yum.conf.psi
69
### move /etc/yum.repos.d, it will interfere with our yum.conf.psi
-
 
70
if [ -e /etc/yum.conf.psi ]; then
75
if [ -d /etc/yum.repos.d ]; then
71
    if [ -d /etc/yum.repos.d ]; then
76
    rm -rf /etc/yum.repos.d.ori
72
	rm -rf /etc/yum.repos.d.ori
77
    mv -f /etc/yum.repos.d /etc/yum.repos.d.ori
73
	mv -f /etc/yum.repos.d /etc/yum.repos.d.ori
-
 
74
    fi
78
fi
75
fi
79
 
76
 
80
### restore folders from /mini
77
### restore folders from /mini
81
echo "restore folders from /mini ..."
78
echo "restore folders from /mini ..."
82
mv /mini/usr/share/doc/* /usr/share/doc/ 2>/dev/null
79
mv /mini/usr/share/doc/* /usr/share/doc/ 2>/dev/null
83
mv /mini/usr/share/backgrounds/images/* /usr/share/backgrounds/images/ 2>/dev/null
80
mv /mini/usr/share/backgrounds/images/* /usr/share/backgrounds/images/ 2>/dev/null
84
if [ -f /mini/usr/share/info/bash.info.gz ]; then
81
if [ -f /mini/usr/share/info/bash.info.gz ]; then
85
    ./mini-livecd.sh -restore
82
    ./mini-livecd.sh -restore
86
fi
83
fi
87
echo "done."
84
echo "done."
88
echo
85
echo
89
 
86
 
90
### restore cronjobs
87
### restore cronjobs
91
mv /etc/cron_backup/sysstat /etc/cron.d/ 2>/dev/null
88
mv /etc/cron_backup/sysstat /etc/cron.d/ 2>/dev/null
92
mv /etc/cron_backup/00-makewhatis.cron.weekly /etc/cron.weekly/00-makewhatis.cron 2>/dev/null
89
mv /etc/cron_backup/00-makewhatis.cron.weekly /etc/cron.weekly/00-makewhatis.cron 2>/dev/null
93
mv /etc/cron_backup/* /etc/cron.daily/
90
mv /etc/cron_backup/* /etc/cron.daily/
94
 
91
 
95
### set root password again
92
### set root password again
96
[ "$SET_ROOTPWD" = "yes" ] && passwd
93
[ "$SET_ROOTPWD" = "yes" ] && passwd
97
if [ "$SET_ROOTPWD" != "yes" ]; then
94
if [ "$SET_ROOTPWD" != "yes" ]; then
98
    echo "Please note:"
95
    echo "Please note:"
99
    echo "If you are not building the LiveCD in chroot,"
96
    echo "If you are not building the LiveCD in chroot,"
100
    echo "root password is unset. Run passwd to set it again."
97
    echo "root password is unset. Run passwd to set it again."
101
fi
98
fi