Subversion Repositories livecd

Rev

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

Rev 169 Rev 255
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
7
# Urs Beyerle
8
#
8
#
9
###############################################################
9
###############################################################
10
 
10
 
11
function usage() {
11
function usage() {
12
 
12
 
13
   ## Usage
13
   ## Usage
14
   # ----------------------------------------------------------
14
   # ----------------------------------------------------------
15
 
15
 
16
   cat <<EOF
16
   cat <<EOF
17
 
17
 
18
   Options:
18
   Options:
19
 
19
 
20
    -h:       print this screen
20
    -h:       print this screen
21
    -psi:     customize for PSI Live CD
21
    -psi:     customize for PSI Live CD
22
 
22
 
23
EOF
23
EOF
24
 
24
 
25
}
25
}
26
 
26
 
27
###############################################################
27
###############################################################
28
 
28
 
29
### read options from command-line
29
### read options from command-line
30
PSI=""
30
PSI=""
31
while [ $# -gt 0 ]; do
31
while [ $# -gt 0 ]; do
32
 
32
 
33
    case "$1" in
33
    case "$1" in
34
       -h)
34
       -h)
35
            usage; exit;;
35
            usage; exit;;
36
       -psi)
36
       -psi)
37
            PSI=true; shift; continue;;
37
            PSI=true; shift; continue;;
38
       *)
38
       *)
39
            usage; exit;;
39
            usage; exit;;
40
    esac
40
    esac
41
 
41
 
42
done
42
done
43
 
43
 
44
### check if I run inside my directory
44
### check if I run inside my directory
45
if [ ! -x $( basename $0 ) ]; then
45
if [ ! -x $( basename $0 ) ]; then
46
    echo "Please run $( basename $0 ) within its directory"
46
    echo "Please run $( basename $0 ) within its directory"
47
    exit 1
47
    exit 1
48
fi
48
fi
49
 
49
 
50
# source livecd.conf
50
# source livecd.conf
51
. livecd.conf
51
. livecd.conf
52
 
52
 
53
LIVECD_DIR=$( pwd )
53
LIVECD_DIR=$( pwd )
54
 
54
 
55
### restore /etc/rc.d/rc.sysinit
55
### restore /etc/rc.d/rc.sysinit
56
cp -a /etc/rc.d/rc.sysinit.ori /etc/rc.d/rc.sysinit
56
cp -a /etc/rc.d/rc.sysinit.ori /etc/rc.d/rc.sysinit
57
 
57
 
58
### enable ssh again
58
### enable ssh again
59
chkconfig sshd on 2>/dev/null
59
chkconfig sshd on 2>/dev/null
60
 
60
 
61
### create link to liblinuxlive
61
### create link to liblinuxlive
62
mkdir -p /livecd/live
62
mkdir -p /livecd/live
63
rm -f /livecd/live/liblinuxlive
63
rm -f /livecd/live/liblinuxlive
64
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
65
 
65
 
66
### restore /etc/resolv.conf
66
### restore /etc/resolv.conf
67
mv -f /etc/resolv.conf.ori /etc/resolv.conf
67
mv -f /etc/resolv.conf.ori /etc/resolv.conf
68
 
68
 
69
### 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
70
if [ -e /etc/yum.conf.psi ]; then
71
    if [ -d /etc/yum.repos.d ]; then
71
    if [ -d /etc/yum.repos.d ]; then
72
	rm -rf /etc/yum.repos.d.ori
72
	rm -rf /etc/yum.repos.d.ori
73
	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
74
    fi
75
fi
75
fi
76
 
76
 
77
### restore folders from /mini
77
### restore folders from /mini
78
echo "restore folders from /mini ..."
78
echo "restore folders from /mini ..."
79
mv /mini/usr/share/doc/* /usr/share/doc/ 2>/dev/null
79
mv /mini/usr/share/doc/* /usr/share/doc/ 2>/dev/null
80
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
-
 
81
mv /mini/usr/share/anaconda/pixmaps/rnotes /usr/share/anaconda/pixmaps/ 2>/dev/null
-
 
82
 
-
 
83
java_src=$( rpm -ql jdk 2>/dev/null | grep /src.zip )
-
 
84
[ "$java_src" ]    && mv -v /mini/src.zip "$java_src"
-
 
85
java_demo=$( rpm -ql jdk | grep /demo$ | head -n 1 )
-
 
86
[ "$java_demo" ]   && mv -v /mini/demo    "$java_demo" 
-
 
87
java_sample=$( rpm -ql jdk | grep /sample$ | head -n 1 )
-
 
88
[ "$java_sample" ] && mv -v /mini/sample  "$java_sample" 
-
 
89
 
-
 
90
java_src=$( rpm -ql j2sdk 2>/dev/null | grep /src.zip )
-
 
91
[ "$java_src" ]    && mv -v /mini/src.zip "$java_src"
-
 
92
java_demo=$( rpm -ql j2sdk | grep /demo$ | head -n 1 )
-
 
93
[ "$java_demo" ]   && mv -v /mini/demo    "$java_demo" 
-
 
94
java_sample=$( rpm -ql j2sdk | grep /sample$ | head -n 1 )
-
 
95
[ "$java_sample" ] && mv -v /mini/sample  "$java_sample" 
-
 
96
 
81
if [ -f /mini/usr/share/info/bash.info.gz ]; then
97
if [ -f /mini/usr/share/info/bash.info.gz ]; then
82
    ./mini-livecd.sh -restore
98
    ./mini-livecd.sh -restore
83
fi
99
fi
-
 
100
 
84
echo "done."
101
echo "done."
85
echo
102
echo
86
 
103
 
87
### restore cronjobs
104
### restore cronjobs
88
mv /etc/cron_backup/sysstat /etc/cron.d/ 2>/dev/null
105
mv /etc/cron_backup/sysstat /etc/cron.d/ 2>/dev/null
89
mv /etc/cron_backup/00-makewhatis.cron.weekly /etc/cron.weekly/00-makewhatis.cron 2>/dev/null
106
mv /etc/cron_backup/00-makewhatis.cron.weekly /etc/cron.weekly/00-makewhatis.cron 2>/dev/null
90
mv /etc/cron_backup/* /etc/cron.daily/
107
mv /etc/cron_backup/* /etc/cron.daily/
91
 
108
 
92
### set root password again
109
### set root password again
93
[ "$SET_ROOTPWD" = "yes" ] && passwd
110
[ "$SET_ROOTPWD" = "yes" ] && passwd
94
if [ "$SET_ROOTPWD" != "yes" ]; then
111
if [ "$SET_ROOTPWD" != "yes" ]; then
95
    echo "Please note:"
112
    echo "Please note:"
96
    echo "If you are not building the LiveCD in chroot,"
113
    echo "If you are not building the LiveCD in chroot,"
97
    echo "root password is unset. Run passwd to set it again."
114
    echo "root password is unset. Run passwd to set it again."
98
fi
115
fi