Subversion Repositories livecd

Rev

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

Rev 222 Rev 230
1
 
-
 
2
 
-
 
3
#!/bin/bash
1
#!/bin/bash
4
#
2
#
5
################################################################
3
################################################################
6
#
4
#
7
# Used to build a MINI LiveCD
5
# Used to build a MINI LiveCD
8
# - save diskspace by moving folders to /mini
6
# - save diskspace by moving folders to /mini
9
#   disable this with "-nomove" option !
7
#   disable this with "-nomove" option !
10
# - direct login to icewm as LOCALUSER
8
# - direct login to icewm as LOCALUSER
11
#   or as root (option -rootlogin)
9
#   or as root (option -rootlogin)
12
# - configure icewm
10
# - configure icewm
13
# - run "minil-livecd -restore" to restore files from /mini again
11
# - run "minil-livecd -restore" to restore files from /mini again
14
#
12
#
15
# Urs Beyerle
13
# Urs Beyerle
16
#
14
#
17
################################################################
15
################################################################
18
 
16
 
19
# source livecd.conf
17
# source livecd.conf
20
. livecd.conf
18
. livecd.conf
21
 
19
 
22
###############################################################
20
###############################################################
23
 
21
 
24
### -----------------------------------------------------------
22
### -----------------------------------------------------------
25
### List of folders (or files) to move:
23
### List of folders (or files) to move:
26
### -----------------------------------------------------------
24
### -----------------------------------------------------------
27
FOLDERS="/usr/src \
25
FOLDERS="/usr/src \
28
         /usr/share/doc \
26
         /usr/share/doc \
29
         /usr/share/info \
27
         /usr/share/info \
30
         /usr/share/anaconda \
28
         /usr/share/anaconda \
31
         /usr/share/gdm \
29
         /usr/share/gdm \
32
         /var/cache/yum \
30
         /var/cache/yum \
33
         /etc/cups/ppds.dat \
31
         /etc/cups/ppds.dat \
34
         /etc/gconf/gconf.xml.defaults \
32
         /etc/gconf/gconf.xml.defaults \
35
         /usr/X11R6/lib/X11/doc \
33
         /usr/X11R6/lib/X11/doc \
36
         /usr/share/vim/vim63/doc \
34
         /usr/share/vim/vim63/doc \
37
         /usr/share/vim/vim63/lang \
35
         /usr/share/vim/vim63/lang \
38
         /usr/share/emacs/21.3/etc/DOC-21.3.1 \
36
         /usr/share/emacs/21.3/etc/DOC-21.3.1 \
39
         /usr/share/pixmaps/nautilus \
37
         /usr/share/pixmaps/nautilus \
40
         /usr/share/cups \
38
         /usr/share/cups \
41
	 /usr/share/icons"
39
	 /usr/share/icons"
42
 
40
 
43
#        /var/lib/rpm \
41
#        /var/lib/rpm \
44
 
42
 
45
### -----------------------------------------------------------
43
### -----------------------------------------------------------
46
### locales we don't need, we keep: en, de, fr
44
### locales we don't need, we keep: en, de, fr
47
### ----------------------------------------------------------- 
45
### ----------------------------------------------------------- 
48
 
46
 
49
### /usr/share/locale
47
### /usr/share/locale
50
### ----------------------------------------------------------- 
48
### ----------------------------------------------------------- 
51
 
49
 
52
# do we restore?
50
# do we restore?
53
if [ -d /mini/usr/share/locale/zh_TW.Big5 ]; then
51
if [ -d /mini/usr/share/locale/zh_TW.Big5 ]; then
54
    MOVE_LOCALE=$( find /mini/usr/share/locale/* -maxdepth 0 -type d  \
52
    MOVE_LOCALE=$( find /mini/usr/share/locale/* -maxdepth 0 -type d  \
55
	      | while read f; do echo ${f##/mini}; done )
53
	      | while read f; do echo ${f##/mini}; done )
56
else
54
else
57
    MOVE_LOCALE=$( find /usr/share/locale/* -maxdepth 0 -type d \
55
    MOVE_LOCALE=$( find /usr/share/locale/* -maxdepth 0 -type d \
58
              | grep -v en | grep -v de | grep -v fr )
56
              | grep -v en | grep -v de | grep -v fr )
59
fi
57
fi
60
 
58
 
61
# add to FOLDERS
59
# add to FOLDERS
62
FOLDERS="$FOLDERS $MOVE_LOCALE"      
60
FOLDERS="$FOLDERS $MOVE_LOCALE"      
63
 
61
 
64
### /mini/usr/share/backgrounds/images/
62
### /mini/usr/share/backgrounds/images/
65
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 
66
 
64
 
67
### /usr/lib/locale
65
### /usr/lib/locale
68
### ----------------------------------------------------------- 
66
### ----------------------------------------------------------- 
69
 
67
 
70
# do we restore?
68
# do we restore?
71
if [ -d /mini/usr/lib/locale/zh_TW ]; then
69
if [ -d /mini/usr/lib/locale/zh_TW ]; then
72
    MOVE_LOCALE=$( find /mini/usr/lib/locale/* -maxdepth 0 -type d  \
70
    MOVE_LOCALE=$( find /mini/usr/lib/locale/* -maxdepth 0 -type d  \
73
	      | while read f; do echo ${f##/mini}; done )
71
	      | while read f; do echo ${f##/mini}; done )
74
else
72
else
75
    MOVE_LOCALE=$( find /usr/lib/locale/* -maxdepth 0 -type d \
73
    MOVE_LOCALE=$( find /usr/lib/locale/* -maxdepth 0 -type d \
76
              | grep -v en | grep -v de | grep -v fr )
74
              | grep -v en | grep -v de | grep -v fr )
77
fi
75
fi
78
 
76
 
79
# add to FOLDERS
77
# add to FOLDERS
80
FOLDERS="$FOLDERS $MOVE_LOCALE"      
78
FOLDERS="$FOLDERS $MOVE_LOCALE"      
81
 
79
 
82
### /usr/share/i18n/locales
80
### /usr/share/i18n/locales
83
### ----------------------------------------------------------- 
81
### ----------------------------------------------------------- 
84
 
82
 
85
# do we restore?
83
# do we restore?
86
if [ -d /mini/usr/share/i18n/locales/zh_TW ]; then
84
if [ -d /mini/usr/share/i18n/locales/zh_TW ]; then
87
    MOVE_LOCALE=$( find /mini/usr/share/i18n/locales/*  -maxdepth 0 -type f \
85
    MOVE_LOCALE=$( find /mini/usr/share/i18n/locales/*  -maxdepth 0 -type f \
88
	      | while read f; do echo ${f##/mini}; done )
86
	      | while read f; do echo ${f##/mini}; done )
89
else
87
else
90
    MOVE_LOCALE=$( find /usr/share/i18n/locales/*  -maxdepth 0 -type f \
88
    MOVE_LOCALE=$( find /usr/share/i18n/locales/*  -maxdepth 0 -type f \
91
              | grep -v en | grep -v de | grep -v fr | grep -v POSIX )
89
              | grep -v en | grep -v de | grep -v fr | grep -v POSIX )
92
fi
90
fi
93
 
91
 
94
# add to FOLDERS
92
# add to FOLDERS
95
FOLDERS="$FOLDERS $MOVE_LOCALE"      
93
FOLDERS="$FOLDERS $MOVE_LOCALE"      
96
 
94
 
97
 
95
 
98
### -----------------------------------------------------------
96
### -----------------------------------------------------------
99
function usage() {
97
function usage() {
100
 
98
 
101
   ## Usage
99
   ## Usage
102
   # ----------------------------------------------------------
100
   # ----------------------------------------------------------
103
 
101
 
104
   cat <<EOF
102
   cat <<EOF
105
 
103
 
106
   Options:
104
   Options:
107
 
105
 
108
    -h:         print this screen
106
    -h:         print this screen
109
    -restore:   restores the folders saved in /mini
107
    -restore:   restores the folders saved in /mini
110
    -nomove:    do not move to /mini
108
    -nomove:    do not move to /mini
111
    -rootlogin: login directly as root and not as LOCALUSER
109
    -rootlogin: login directly as root and not as LOCALUSER
112
    -psi:       build for PSI
110
    -psi:       build for PSI
113
 
111
 
114
EOF
112
EOF
115
 
113
 
116
}
114
}
117
 
115
 
118
 
116
 
119
### -----------------------------------------------------------
117
### -----------------------------------------------------------
120
### read options from command-line
118
### read options from command-line
121
RESTORE=""
119
RESTORE=""
122
while [ $# -gt 0 ]; do
120
while [ $# -gt 0 ]; do
123
 
121
 
124
    case "$1" in
122
    case "$1" in
125
       -h)
123
       -h)
126
            usage; exit;;
124
            usage; exit;;
127
       -restore)
125
       -restore)
128
            RESTORE="-restore"; shift; continue;;
126
            RESTORE="-restore"; shift; continue;;
129
       -psi)
127
       -psi)
130
            PSI="-psi"; shift; continue;;
128
            PSI="-psi"; shift; continue;;
131
       -nomove)
129
       -nomove)
132
            NOMOVE="-nomove"; shift; continue;;
130
            NOMOVE="-nomove"; shift; continue;;
133
       -rootlogin)
131
       -rootlogin)
134
            ROOTLOGIN="-rootlogin"; shift; continue;;
132
            ROOTLOGIN="-rootlogin"; shift; continue;;
135
       *)
133
       *)
136
            usage; exit;;
134
            usage; exit;;
137
    esac
135
    esac
138
 
136
 
139
done
137
done
140
 
138
 
141
 
139
 
142
### -----------------------------------------------------------
140
### -----------------------------------------------------------
143
### LOCALUSER name?
141
### LOCALUSER name?
144
if [ $PSI ]; then 
142
if [ $PSI ]; then 
145
    LOCALUSER=l_psi
143
    LOCALUSER=l_psi
146
else
144
else
147
    LOCALUSER=sluser
145
    LOCALUSER=sluser
148
fi
146
fi
149
 
147
 
150
 
148
 
151
### -----------------------------------------------------------
149
### -----------------------------------------------------------
152
### Modifications for Mini LivdCD
150
### Modifications for Mini LiveCD
153
if [ ! $RESTORE ]; then
151
if [ ! $RESTORE ]; then
154
    
152
    
155
    if [ ! $NOMOVE ]; then
153
    if [ ! $NOMOVE ]; then
156
	echo
154
	echo
157
	echo "--------------------------------------------"
155
	echo "--------------------------------------------"
158
	echo "Save diskspace by moving folders to /mini:"
156
	echo "Save diskspace by moving folders to /mini:"
159
	echo "--------------------------------------------"
157
	echo "--------------------------------------------"
160
 
158
 
161
	mkdir -p /mini
159
	mkdir -p /mini
162
	for folder in $FOLDERS; do
160
	for folder in $FOLDERS; do
163
	    echo "Move $folder"
161
	    echo "Move $folder"
164
	    name=$( basename $folder )
162
	    name=$( basename $folder )
165
	    base=${folder%$name}
163
	    base=${folder%$name}
166
	    mkdir -p /mini/${base}
164
	    mkdir -p /mini/${base}
167
	    mv ${folder} /mini${base}
165
	    mv ${folder} /mini${base}
168
	done
166
	done
169
    fi
167
    fi
170
 
168
 
171
    ### emacs-21.3 and emacs are hard links (and large 4.3MB) 
-
 
172
    if [ -f /usr/bin/emacs-21.3 ]; then
-
 
173
	rm /usr/bin/emacs-21.3
-
 
174
	ln -s emacs /usr/bin/emacs-21.3
-
 
175
    fi
-
 
176
 
-
 
177
    ### run updatedb
169
    ### run updatedb
178
    echo "Run updatedb..."
170
    echo "Run updatedb..."
179
    . /etc/updatedb.conf 2>/dev/null
171
    . /etc/updatedb.conf 2>/dev/null
180
    rpm -q mlocate >/dev/null
172
    rpm -q mlocate >/dev/null
181
    if [ "$?" = "0" ]; then
173
    if [ "$?" = "0" ]; then
182
	/usr/bin/updatedb -e "/media /sfs /tmp /boot /livecd /home /net /trunk"
174
	/usr/bin/updatedb -e "/media /sfs /tmp /boot /livecd /home /net /trunk"
183
    else
175
    else
184
	/usr/bin/updatedb -e /media,/tmp,/boot,/livecd,/home,/net,/trunk
176
	/usr/bin/updatedb -e /media,/tmp,/boot,/livecd,/home,/net,/trunk
185
    fi
177
    fi
186
    echo "done."
178
    echo "done."
187
 
179
 
188
    ### change init runlevel to 3
180
    ### change init runlevel to 3
189
    sed -i "s/id\:.\:initdefault/id\:3\:initdefault/" /etc/inittab
181
    sed -i "s/id\:.\:initdefault/id\:3\:initdefault/" /etc/inittab
190
 
182
 
191
    ### autologin at tty6
183
    ### autologin at tty6
192
    if [ $ROOTLOGIN ]; then
184
    if [ $ROOTLOGIN ]; then
193
	line="6:2345:respawn:\/sbin\/mingetty --autologin root tty6"
185
	line="6:2345:respawn:\/sbin\/mingetty --autologin root tty6"
194
	# modify .bashrc for root
186
	# modify .bashrc for root
195
	grep -q "/dev/tty6" /root/.bashrc
187
	grep -q "/dev/tty6" /root/.bashrc
196
	if [ "$?" = "1" ]; then
188
	if [ "$?" = "1" ]; then
197
	    echo 'if [ "$( tty )" = "/dev/tty6" ]; then startx; fi' >> /root/.bashrc
189
	    echo 'if [ "$( tty )" = "/dev/tty6" ]; then startx; fi' >> /root/.bashrc
198
	fi
190
	fi
199
    else
191
    else
200
	line="6:2345:respawn:\/sbin\/mingetty --autologin $LOCALUSER tty6"
192
	line="6:2345:respawn:\/sbin\/mingetty --autologin $LOCALUSER tty6"
201
    fi
193
    fi
202
    sed -i "s/.*respawn.*tty6.*/$line/" /etc/inittab
194
    sed -i "s/.*respawn.*tty6.*/$line/" /etc/inittab
203
 
195
 
204
    ### /etc/rc.d/init.d/login
196
    ### /etc/rc.d/init.d/login
205
    ### Provides directly login over xinit
197
    ### Provides directly login over xinit
206
    cp -a customize/login /etc/rc.d/init.d/login
198
    cp -a customize/login /etc/rc.d/init.d/login
207
    chmod +x /etc/rc.d/init.d/login
199
    chmod +x /etc/rc.d/init.d/login
208
    
200
    
209
    ### modify /etc/rc.d/init.d/runlast
201
    ### modify /etc/rc.d/init.d/runlast: add /etc/init.d/login at the end
210
    RUNLAST=/etc/rc.d/init.d/runlast
202
    RUNLAST=/etc/rc.d/init.d/runlast
211
    echo >> $RUNLAST
203
    echo >> $RUNLAST
212
    echo "### execute /etc/init.d/login for direct login" >> $RUNLAST
204
    echo "### execute /etc/init.d/login for direct login" >> $RUNLAST
213
    echo "/etc/init.d/login" >> $RUNLAST
205
    echo "/etc/init.d/login" >> $RUNLAST
214
    echo >> $RUNLAST
206
    echo >> $RUNLAST
215
 
207
 
216
    ### remove kde profile
-
 
217
    rm -f /etc/profile.d/kde*
-
 
218
 
-
 
219
    ### configure ICEWM
-
 
220
    cp -a customize/icewm/winoptions /usr/share/icewm/
-
 
221
    cp -a customize/icewm/toolbar /usr/share/icewm/
-
 
222
    cp -a customize/icewm/menu /usr/share/icewm/
-
 
223
 
-
 
224
    ### default theme for ICEWM
-
 
225
    rpm -q icewm-SL-theme >/dev/null 2>&1
-
 
226
    if [ "$?" = "0" ]; then
-
 
227
	echo "Theme=SL/default.theme" > /usr/share/icewm/theme
-
 
228
    fi
-
 
229
 
-
 
230
    ### delete "mozilla" lines, if no mozilla is installed
-
 
231
    if [ ! -x /usr/bin/mozilla ]; then
-
 
232
	sed -i "/mozilla/d" /usr/share/icewm/winoptions
-
 
233
	sed -i "/mozilla/d" /usr/share/icewm/toolbar
-
 
234
	sed -i "/mozilla/d" /usr/share/icewm/menu	
-
 
235
    fi
-
 
236
 
-
 
237
    ### icons for icewm
-
 
238
    cp -a /usr/share/pixmaps/qtparted.xpm /usr/share/icewm/icons/ 2>/dev/null
-
 
239
    cp -a /usr/share/gftp/gftp.xpm /usr/share/icewm/icons/ 2>/dev/null
-
 
240
 
-
 
241
    ### no rdesktop menu entry on non PSI systems
-
 
242
    if [ ! $PSI ];then
-
 
243
	sed -i "/prog Rdesktop.*/d" /usr/share/icewm/menu
-
 
244
    fi
-
 
245
 
-
 
246
    ### create some pam.d files
-
 
247
    # cp -a /etc/pam.d/system-config-display /etc/pam.d/partimage
-
 
248
 
-
 
249
 
208
 
250
### -----------------------------------------------------------
209
### -----------------------------------------------------------
251
### Restores some modifications
210
### Restores some modifications
252
else
211
else
253
 
212
 
254
    if [ ! $NOMOVE ]; then
213
    if [ ! $NOMOVE ]; then
255
        ### remove default html page
214
        ### remove default html page
256
	rm /usr/share/doc/HTML/index.html
215
	rm /usr/share/doc/HTML/index.html
257
	rm -rf /usr/share/doc/livecd
216
	rm -rf /usr/share/doc/livecd
258
	rmdir /usr/share/doc/HTML
217
	rmdir /usr/share/doc/HTML
259
	rmdir /usr/share/doc
218
	rmdir /usr/share/doc
260
 
219
 
261
	echo
220
	echo
262
	echo "--------------------------------------------"
221
	echo "--------------------------------------------"
263
	echo "Restore folders saved in /mini:"
222
	echo "Restore folders saved in /mini:"
264
	echo "--------------------------------------------"
223
	echo "--------------------------------------------"
265
	for folder in $FOLDERS; do
224
	for folder in $FOLDERS; do
266
	    echo "Restore $folder"
225
	    echo "Restore $folder"
267
	    name=$( basename $folder )
226
	    name=$( basename $folder )
268
	    base=${folder%$name}
227
	    base=${folder%$name}
269
	    mv /mini${folder} ${base}
228
	    mv /mini${folder} ${base}
270
	done
229
	done
271
	mv /mini/usr/share/i18n/locales/* /usr/share/i18n/locales/
230
	mv /mini/usr/share/i18n/locales/* /usr/share/i18n/locales/
272
	echo "done."
231
	echo "done."
273
    fi
232
    fi
274
fi
233
fi
275
 
234
 
276
 
235
 
277
echo "--------------------------------------------"
236
echo "--------------------------------------------"
278
echo "End of mini-livecd.sh" 
237
echo "End of mini-livecd.sh" 
279
echo "--------------------------------------------"
238
echo "--------------------------------------------"
280
echo
239
echo