Subversion Repositories livecd

Rev

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

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