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