Subversion Repositories livecd

Rev

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

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