Subversion Repositories livecd

Rev

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

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