Subversion Repositories livecd

Rev

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

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