Subversion Repositories livecd

Rev

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