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
33 beyerle@PS 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
1 beyerle@PS 197
 
198
    ### modify /etc/rc.d/init.d/runlast
199
    RUNLAST=/etc/rc.d/init.d/runlast
200
    echo >> $RUNLAST
201
    echo "### execute /etc/init.d/login for direct login" >> $RUNLAST
202
    echo "/etc/init.d/login" >> $RUNLAST
203
    echo >> $RUNLAST
204
 
205
    ### remove kde profile
206
    rm -f /etc/profile.d/kde*
207
 
208
    ### configure ICEWM
209
    cp -a customize/icewm/winoptions /usr/share/icewm/
210
    cp -a customize/icewm/toolbar /usr/share/icewm/
211
    cp -a customize/icewm/menu /usr/share/icewm/
212
 
213
    ### delete "mozilla" lines, if no mozilla is installed
214
    if [ ! -x /usr/bin/mozilla ]; then
215
	sed -i "/mozilla/d" /usr/share/icewm/winoptions
216
	sed -i "/mozilla/d" /usr/share/icewm/toolbar
217
	sed -i "/mozilla/d" /usr/share/icewm/menu	
218
    fi
219
 
220
    ### icons for icewm
221
    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
223
 
224
    ### no rdesktop menu entry on non PSI systems
225
    if [ ! $PSI ];then
226
	sed -i "/prog Rdesktop.*/d" /usr/share/icewm/menu
227
    fi
228
 
229
    ### create some pam.d files
230
    # cp -a /etc/pam.d/system-config-display /etc/pam.d/partimage
231
 
232
 
233
### -----------------------------------------------------------
234
### Restores some modifications
235
else
236
 
237
    if [ ! $NOMOVE ]; then
238
        ### remove default html page
239
	rm /usr/share/doc/HTML/index.html
240
	rm -rf /usr/share/doc/livecd
241
	rmdir /usr/share/doc/HTML
242
	rmdir /usr/share/doc
243
 
244
	echo
245
	echo "--------------------------------------------"
246
	echo "Restore folders saved in /mini:"
247
	echo "--------------------------------------------"
248
	for folder in $FOLDERS; do
249
	    echo "Restore $folder"
250
	    name=$( basename $folder )
251
	    base=${folder%$name}
252
	    mv /mini${folder} ${base}
253
	done
254
	mv /mini/usr/share/i18n/locales/* /usr/share/i18n/locales/
255
	echo "done."
256
    fi
257
fi
258
 
259
 
260
echo "--------------------------------------------"
261
echo "End of mini-livecd.sh" 
262
echo "--------------------------------------------"
263
echo