Subversion Repositories livecd

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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