Subversion Repositories livecd

Rev

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

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