Subversion Repositories livecd

Rev

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

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