Subversion Repositories livecd

Rev

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

Rev 267 Rev 335
1
#!/bin/bash
1
#!/bin/bash
2
#
2
#
3
################################################################
3
################################################################
4
#
4
#
5
# Used to build a MINI LiveCD
5
# Used to build a MINI LiveCD
6
# - save diskspace by moving folders to /mini
6
# - save diskspace by moving folders to /mini
7
#   disable this with "-nomove" option !
7
#   disable this with "-nomove" option !
8
# - direct login to icewm as LOCALUSER
8
# - direct login to icewm as LOCALUSER
9
#   or as root (option -rootlogin)
9
#   or as root (option -rootlogin)
10
# - configure icewm
10
# - configure icewm
11
# - run "minil-livecd -restore" to restore files from /mini again
11
# - run "minil-livecd -restore" to restore files from /mini again
12
#
12
#
13
# Urs Beyerle
13
# Urs Beyerle
14
#
14
#
15
################################################################
15
################################################################
16
 
16
 
17
# source livecd.conf
17
# source livecd.conf
18
. livecd.conf
18
. livecd.conf
19
 
19
 
20
###############################################################
20
###############################################################
21
 
21
 
22
### -----------------------------------------------------------
22
### -----------------------------------------------------------
23
### List of folders (or files) to move:
23
### List of folders (or files) to move:
24
### -----------------------------------------------------------
24
### -----------------------------------------------------------
25
FOLDERS="/usr/src \
25
FOLDERS="/usr/src \
26
         /usr/share/doc \
26
         /usr/share/doc \
27
         /usr/share/info \
27
         /usr/share/info \
28
         /usr/share/anaconda \
28
         /usr/share/anaconda \
29
         /usr/share/gdm \
29
         /usr/share/gdm \
30
         /var/cache/yum \
30
         /var/cache/yum \
31
         /etc/cups/ppds.dat \
31
         /etc/cups/ppds.dat \
32
         /etc/gconf/gconf.xml.defaults \
32
         /etc/gconf/gconf.xml.defaults \
33
         /usr/X11R6/lib/X11/doc \
33
         /usr/X11R6/lib/X11/doc \
34
         /usr/share/vim/vim70/doc \
34
         /usr/share/vim/vim70/doc \
35
         /usr/share/vim/vim70/lang \
35
         /usr/share/vim/vim70/lang \
36
         /usr/share/emacs/21.4/etc/DOC-21.4.1 \
36
         /usr/share/emacs/21.4/etc/DOC-21.4.1 \
37
         /usr/share/pixmaps/nautilus \
37
         /usr/share/pixmaps/nautilus \
38
         /usr/share/cups \
38
         /usr/share/cups \
39
	 /usr/share/icons"
39
	 /usr/share/icons"
40
 
40
 
41
#        /var/lib/rpm \
41
#        /var/lib/rpm \
42
 
42
 
43
### -----------------------------------------------------------
43
### -----------------------------------------------------------
44
### locales we don't need, we keep: en, de, fr
44
### locales we don't need, we keep: en, de, fr
45
### ----------------------------------------------------------- 
45
### ----------------------------------------------------------- 
46
 
46
 
47
### /usr/share/locale
47
### /usr/share/locale
48
### ----------------------------------------------------------- 
48
### ----------------------------------------------------------- 
49
 
49
 
50
# do we restore?
50
# do we restore?
51
if [ -d /mini/usr/share/locale/zh_TW.Big5 ]; then
51
if [ -d /mini/usr/share/locale/zh_TW.Big5 ]; then
52
    MOVE_LOCALE=$( find /mini/usr/share/locale/* -maxdepth 0 -type d  \
52
    MOVE_LOCALE=$( find /mini/usr/share/locale/* -maxdepth 0 -type d  \
53
	      | while read f; do echo ${f##/mini}; done )
53
	      | while read f; do echo ${f##/mini}; done )
54
else
54
else
55
    MOVE_LOCALE=$( find /usr/share/locale/* -maxdepth 0 -type d \
55
    MOVE_LOCALE=$( find /usr/share/locale/* -maxdepth 0 -type d \
56
              | grep -v en | grep -v de | grep -v fr )
56
              | grep -v en | grep -v de | grep -v fr )
57
fi
57
fi
58
 
58
 
59
# add to FOLDERS
59
# add to FOLDERS
60
FOLDERS="$FOLDERS $MOVE_LOCALE"      
60
FOLDERS="$FOLDERS $MOVE_LOCALE"      
61
 
61
 
62
### /mini/usr/share/backgrounds/images/
62
### /mini/usr/share/backgrounds/images/
63
mv /mini/usr/share/backgrounds/images/* /usr/share/backgrounds/images/ 2>/dev/null 
63
mv /mini/usr/share/backgrounds/images/* /usr/share/backgrounds/images/ 2>/dev/null 
64
 
64
 
-
 
65
# mysql.info.gz
-
 
66
mv -v /mini/usr/share/info/mysql.info.gz /usr/share/info/ 2>/dev/null
-
 
67
 
-
 
68
 
65
### /usr/lib/locale
69
### /usr/lib/locale
66
### ----------------------------------------------------------- 
70
### ----------------------------------------------------------- 
67
 
71
 
68
# do we restore?
72
# do we restore?
69
if [ -d /mini/usr/lib/locale/zh_TW ]; then
73
if [ -d /mini/usr/lib/locale/zh_TW ]; then
70
    MOVE_LOCALE=$( find /mini/usr/lib/locale/* -maxdepth 0 -type d  \
74
    MOVE_LOCALE=$( find /mini/usr/lib/locale/* -maxdepth 0 -type d  \
71
	      | while read f; do echo ${f##/mini}; done )
75
	      | while read f; do echo ${f##/mini}; done )
72
else
76
else
73
    MOVE_LOCALE=$( find /usr/lib/locale/* -maxdepth 0 -type d \
77
    MOVE_LOCALE=$( find /usr/lib/locale/* -maxdepth 0 -type d \
74
              | grep -v en | grep -v de | grep -v fr )
78
              | grep -v en | grep -v de | grep -v fr )
75
fi
79
fi
76
 
80
 
77
# add to FOLDERS
81
# add to FOLDERS
78
FOLDERS="$FOLDERS $MOVE_LOCALE"      
82
FOLDERS="$FOLDERS $MOVE_LOCALE"      
79
 
83
 
80
### /usr/share/i18n/locales
84
### /usr/share/i18n/locales
81
### ----------------------------------------------------------- 
85
### ----------------------------------------------------------- 
82
 
86
 
83
# do we restore?
87
# do we restore?
84
if [ -d /mini/usr/share/i18n/locales/zh_TW ]; then
88
if [ -d /mini/usr/share/i18n/locales/zh_TW ]; then
85
    MOVE_LOCALE=$( find /mini/usr/share/i18n/locales/*  -maxdepth 0 -type f \
89
    MOVE_LOCALE=$( find /mini/usr/share/i18n/locales/*  -maxdepth 0 -type f \
86
	      | while read f; do echo ${f##/mini}; done )
90
	      | while read f; do echo ${f##/mini}; done )
87
else
91
else
88
    MOVE_LOCALE=$( find /usr/share/i18n/locales/*  -maxdepth 0 -type f \
92
    MOVE_LOCALE=$( find /usr/share/i18n/locales/*  -maxdepth 0 -type f \
89
              | grep -v en | grep -v de | grep -v fr | grep -v POSIX )
93
              | grep -v en | grep -v de | grep -v fr | grep -v POSIX )
90
fi
94
fi
91
 
95
 
92
# add to FOLDERS
96
# add to FOLDERS
93
FOLDERS="$FOLDERS $MOVE_LOCALE"      
97
FOLDERS="$FOLDERS $MOVE_LOCALE"      
94
 
98
 
95
 
99
 
96
### -----------------------------------------------------------
100
### -----------------------------------------------------------
97
function usage() {
101
function usage() {
98
 
102
 
99
   ## Usage
103
   ## Usage
100
   # ----------------------------------------------------------
104
   # ----------------------------------------------------------
101
 
105
 
102
   cat <<EOF
106
   cat <<EOF
103
 
107
 
104
   Options:
108
   Options:
105
 
109
 
106
    -h:         print this screen
110
    -h:         print this screen
107
    -restore:   restores the folders saved in /mini
111
    -restore:   restores the folders saved in /mini
108
    -nomove:    do not move to /mini
112
    -nomove:    do not move to /mini
109
    -rootlogin: login directly as root and not as LOCALUSER
113
    -rootlogin: login directly as root and not as LOCALUSER
110
    -psi:       build for PSI
114
    -psi:       build for PSI
111
 
115
 
112
EOF
116
EOF
113
 
117
 
114
}
118
}
115
 
119
 
116
 
120
 
117
### -----------------------------------------------------------
121
### -----------------------------------------------------------
118
### read options from command-line
122
### read options from command-line
119
RESTORE=""
123
RESTORE=""
120
while [ $# -gt 0 ]; do
124
while [ $# -gt 0 ]; do
121
 
125
 
122
    case "$1" in
126
    case "$1" in
123
       -h)
127
       -h)
124
            usage; exit;;
128
            usage; exit;;
125
       -restore)
129
       -restore)
126
            RESTORE="-restore"; shift; continue;;
130
            RESTORE="-restore"; shift; continue;;
127
       -psi)
131
       -psi)
128
            PSI="-psi"; shift; continue;;
132
            PSI="-psi"; shift; continue;;
129
       -nomove)
133
       -nomove)
130
            NOMOVE="-nomove"; shift; continue;;
134
            NOMOVE="-nomove"; shift; continue;;
131
       -rootlogin)
135
       -rootlogin)
132
            ROOTLOGIN="-rootlogin"; shift; continue;;
136
            ROOTLOGIN="-rootlogin"; shift; continue;;
133
       *)
137
       *)
134
            usage; exit;;
138
            usage; exit;;
135
    esac
139
    esac
136
 
140
 
137
done
141
done
138
 
142
 
139
 
143
 
140
### -----------------------------------------------------------
144
### -----------------------------------------------------------
141
### LOCALUSER name?
145
### LOCALUSER name?
142
if [ $PSI ]; then 
146
if [ $PSI ]; then 
143
    LOCALUSER=l_psi
147
    LOCALUSER=l_psi
144
else
148
else
145
    LOCALUSER=sluser
149
    LOCALUSER=sluser
146
fi
150
fi
147
 
151
 
148
 
152
 
149
### -----------------------------------------------------------
153
### -----------------------------------------------------------
150
### Modifications for Mini LiveCD
154
### Modifications for Mini LiveCD
151
if [ ! $RESTORE ]; then
155
if [ ! $RESTORE ]; then
152
    
156
    
153
    if [ ! $NOMOVE ]; then
157
    if [ ! $NOMOVE ]; then
154
	echo
158
	echo
155
	echo "--------------------------------------------"
159
	echo "--------------------------------------------"
156
	echo "Save diskspace by moving folders to /mini:"
160
	echo "Save diskspace by moving folders to /mini:"
157
	echo "--------------------------------------------"
161
	echo "--------------------------------------------"
158
 
162
 
159
	mkdir -p /mini
163
	mkdir -p /mini
160
	for folder in $FOLDERS; do
164
	for folder in $FOLDERS; do
161
	    echo "Move $folder"
165
	    echo "Move $folder"
162
	    name=$( basename $folder )
166
	    name=$( basename $folder )
163
	    base=${folder%$name}
167
	    base=${folder%$name}
164
	    mkdir -p /mini/${base}
168
	    mkdir -p /mini/${base}
165
	    mv ${folder} /mini${base}
169
	    mv ${folder} /mini${base}
166
	done
170
	done
167
    fi
171
    fi
168
 
172
 
169
    ### force default runlevel equal 3, if neither xdm, kdm nor gdm is installed
173
    ### force default runlevel equal 3, if neither xdm, kdm nor gdm is installed
170
    which xdm >/dev/null 2>&1 || which kdm >/dev/null 2>&1 || which gdm >/dev/null 2>&1
174
    which xdm >/dev/null 2>&1 || which kdm >/dev/null 2>&1 || which gdm >/dev/null 2>&1
171
    if [ "$?" != "0" ]; then
175
    if [ "$?" != "0" ]; then
172
	sed -i "s/id\:.\:initdefault/id\:3\:initdefault/" /etc/inittab
176
	sed -i "s/id\:.\:initdefault/id\:3\:initdefault/" /etc/inittab
173
    fi
177
    fi
174
 
178
 
175
    ### enable auto login
179
    ### enable auto login
176
    echo "Enable auto login..."
180
    echo "Enable auto login..."
177
    customize/livecd-autologin -u $LOCALUSER on >/dev/null 2>&1
181
    customize/livecd-autologin -u $LOCALUSER on >/dev/null 2>&1
178
    echo "### enable auto login for user $LOCALUSER (livecd-autologin)" >> /etc/rc.d/init.d/runlast
182
    echo "### enable auto login for user $LOCALUSER (livecd-autologin)" >> /etc/rc.d/init.d/runlast
179
    echo "livecd-autologin -u $LOCALUSER on >/dev/null 2>&1"            >> /etc/rc.d/init.d/runlast
183
    echo "livecd-autologin -u $LOCALUSER on >/dev/null 2>&1"            >> /etc/rc.d/init.d/runlast
180
 
184
 
181
    ### run updatedb
185
    ### run updatedb
182
    echo "Run updatedb..."
186
    echo "Run updatedb..."
183
    . /etc/updatedb.conf 2>/dev/null
187
    . /etc/updatedb.conf 2>/dev/null
184
    rpm -q mlocate >/dev/null
188
    rpm -q mlocate >/dev/null
185
    if [ "$?" = "0" ]; then
189
    if [ "$?" = "0" ]; then
186
	/usr/bin/updatedb -e "/media /sfs /tmp /boot /livecd /home /net /trunk"
190
	/usr/bin/updatedb -e "/media /sfs /tmp /boot /livecd /home /net /trunk"
187
    else
191
    else
188
	/usr/bin/updatedb -e /media,/tmp,/boot,/livecd,/home,/net,/trunk
192
	/usr/bin/updatedb -e /media,/tmp,/boot,/livecd,/home,/net,/trunk
189
    fi
193
    fi
190
    echo "done."
194
    echo "done."
191
 
195
 
192
 
196
 
193
 
197
 
194
### -----------------------------------------------------------
198
### -----------------------------------------------------------
195
### Restores some modifications
199
### Restores some modifications
196
else
200
else
197
 
201
 
198
    if [ ! $NOMOVE ]; then
202
    if [ ! $NOMOVE ]; then
199
        ### remove default html page
203
        ### remove default html page
200
	rm /usr/share/doc/HTML/index.html
204
	rm /usr/share/doc/HTML/index.html
201
	rm -rf /usr/share/doc/livecd
205
	rm -rf /usr/share/doc/livecd
202
	rmdir /usr/share/doc/HTML
206
	rmdir /usr/share/doc/HTML
203
	rmdir /usr/share/doc
207
	rmdir /usr/share/doc
204
 
208
 
205
	echo
209
	echo
206
	echo "--------------------------------------------"
210
	echo "--------------------------------------------"
207
	echo "Restore folders saved in /mini:"
211
	echo "Restore folders saved in /mini:"
208
	echo "--------------------------------------------"
212
	echo "--------------------------------------------"
209
	for folder in $FOLDERS; do
213
	for folder in $FOLDERS; do
210
	    echo "Restore $folder"
214
	    echo "Restore $folder"
211
	    name=$( basename $folder )
215
	    name=$( basename $folder )
212
	    base=${folder%$name}
216
	    base=${folder%$name}
213
	    mv /mini${folder} ${base}
217
	    mv /mini${folder} ${base}
214
	done
218
	done
215
	mv /mini/usr/share/i18n/locales/* /usr/share/i18n/locales/
219
	mv /mini/usr/share/i18n/locales/* /usr/share/i18n/locales/
216
	echo "done."
220
	echo "done."
217
    fi
221
    fi
218
 
222
 
219
    ### disable auto login
223
    ### disable auto login
220
    echo "Disable auto login..."
224
    echo "Disable auto login..."
221
    customize/livecd-autologin -u $LOCALUSER off >/dev/null 2>&1
225
    customize/livecd-autologin -u $LOCALUSER off >/dev/null 2>&1
222
    sed -i "/.*livecd-autologin.*/d" /etc/rc.d/init.d/runlast
226
    sed -i "/.*livecd-autologin.*/d" /etc/rc.d/init.d/runlast
223
 
227
 
224
fi
228
fi
225
 
229
 
226
 
230
 
227
echo "--------------------------------------------"
231
echo "--------------------------------------------"
228
echo "End of mini-livecd.sh" 
232
echo "End of mini-livecd.sh" 
229
echo "--------------------------------------------"
233
echo "--------------------------------------------"
230
echo
234
echo