Subversion Repositories livecd

Rev

Rev 169 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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