Subversion Repositories livecd

Rev

Rev 267 | 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
#
169 beyerle@PS 13
# Urs Beyerle
1 beyerle@PS 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 \
234 beyerleu 34
         /usr/share/vim/vim70/doc \
35
         /usr/share/vim/vim70/lang \
36
         /usr/share/emacs/21.4/etc/DOC-21.4.1 \
1 beyerle@PS 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
 
117 beyerle@PS 62
### /mini/usr/share/backgrounds/images/
63
mv /mini/usr/share/backgrounds/images/* /usr/share/backgrounds/images/ 2>/dev/null 
64
 
335 beyerleu 65
# mysql.info.gz
66
mv -v /mini/usr/share/info/mysql.info.gz /usr/share/info/ 2>/dev/null
67
 
68
 
1 beyerle@PS 69
### /usr/lib/locale
70
### ----------------------------------------------------------- 
71
 
72
# do we restore?
73
if [ -d /mini/usr/lib/locale/zh_TW ]; then
94 beyerle@PS 74
    MOVE_LOCALE=$( find /mini/usr/lib/locale/* -maxdepth 0 -type d  \
1 beyerle@PS 75
	      | while read f; do echo ${f##/mini}; done )
76
else
94 beyerle@PS 77
    MOVE_LOCALE=$( find /usr/lib/locale/* -maxdepth 0 -type d \
1 beyerle@PS 78
              | grep -v en | grep -v de | grep -v fr )
79
fi
80
 
81
# add to FOLDERS
82
FOLDERS="$FOLDERS $MOVE_LOCALE"      
83
 
84
### /usr/share/i18n/locales
85
### ----------------------------------------------------------- 
86
 
87
# do we restore?
88
if [ -d /mini/usr/share/i18n/locales/zh_TW ]; then
94 beyerle@PS 89
    MOVE_LOCALE=$( find /mini/usr/share/i18n/locales/*  -maxdepth 0 -type f \
1 beyerle@PS 90
	      | while read f; do echo ${f##/mini}; done )
91
else
94 beyerle@PS 92
    MOVE_LOCALE=$( find /usr/share/i18n/locales/*  -maxdepth 0 -type f \
1 beyerle@PS 93
              | grep -v en | grep -v de | grep -v fr | grep -v POSIX )
94
fi
95
 
96
# add to FOLDERS
97
FOLDERS="$FOLDERS $MOVE_LOCALE"      
98
 
99
 
100
### -----------------------------------------------------------
101
function usage() {
102
 
103
   ## Usage
104
   # ----------------------------------------------------------
105
 
106
   cat <<EOF
107
 
108
   Options:
109
 
110
    -h:         print this screen
111
    -restore:   restores the folders saved in /mini
112
    -nomove:    do not move to /mini
113
    -rootlogin: login directly as root and not as LOCALUSER
114
    -psi:       build for PSI
115
 
116
EOF
117
 
118
}
119
 
120
 
121
### -----------------------------------------------------------
122
### read options from command-line
123
RESTORE=""
124
while [ $# -gt 0 ]; do
125
 
126
    case "$1" in
127
       -h)
128
            usage; exit;;
129
       -restore)
130
            RESTORE="-restore"; shift; continue;;
131
       -psi)
132
            PSI="-psi"; shift; continue;;
133
       -nomove)
134
            NOMOVE="-nomove"; shift; continue;;
135
       -rootlogin)
136
            ROOTLOGIN="-rootlogin"; shift; continue;;
137
       *)
138
            usage; exit;;
139
    esac
140
 
141
done
142
 
143
 
144
### -----------------------------------------------------------
145
### LOCALUSER name?
146
if [ $PSI ]; then 
147
    LOCALUSER=l_psi
148
else
149
    LOCALUSER=sluser
150
fi
151
 
152
 
153
### -----------------------------------------------------------
230 beyerleu 154
### Modifications for Mini LiveCD
1 beyerle@PS 155
if [ ! $RESTORE ]; then
156
 
157
    if [ ! $NOMOVE ]; then
158
	echo
159
	echo "--------------------------------------------"
160
	echo "Save diskspace by moving folders to /mini:"
161
	echo "--------------------------------------------"
162
 
163
	mkdir -p /mini
164
	for folder in $FOLDERS; do
165
	    echo "Move $folder"
166
	    name=$( basename $folder )
167
	    base=${folder%$name}
168
	    mkdir -p /mini/${base}
169
	    mv ${folder} /mini${base}
170
	done
171
    fi
172
 
235 beyerleu 173
    ### force default runlevel equal 3, if neither xdm, kdm nor gdm is installed
174
    which xdm >/dev/null 2>&1 || which kdm >/dev/null 2>&1 || which gdm >/dev/null 2>&1
175
    if [ "$?" != "0" ]; then
176
	sed -i "s/id\:.\:initdefault/id\:3\:initdefault/" /etc/inittab
177
    fi
178
 
231 beyerleu 179
    ### enable auto login
233 beyerleu 180
    echo "Enable auto login..."
231 beyerleu 181
    customize/livecd-autologin -u $LOCALUSER on >/dev/null 2>&1
233 beyerleu 182
    echo "### enable auto login for user $LOCALUSER (livecd-autologin)" >> /etc/rc.d/init.d/runlast
183
    echo "livecd-autologin -u $LOCALUSER on >/dev/null 2>&1"            >> /etc/rc.d/init.d/runlast
231 beyerleu 184
 
1 beyerle@PS 185
    ### run updatedb
186
    echo "Run updatedb..."
94 beyerle@PS 187
    . /etc/updatedb.conf 2>/dev/null
188
    rpm -q mlocate >/dev/null
189
    if [ "$?" = "0" ]; then
190
	/usr/bin/updatedb -e "/media /sfs /tmp /boot /livecd /home /net /trunk"
191
    else
192
	/usr/bin/updatedb -e /media,/tmp,/boot,/livecd,/home,/net,/trunk
193
    fi
1 beyerle@PS 194
    echo "done."
195
 
196
 
33 beyerle@PS 197
 
1 beyerle@PS 198
### -----------------------------------------------------------
199
### Restores some modifications
200
else
201
 
202
    if [ ! $NOMOVE ]; then
203
        ### remove default html page
204
	rm /usr/share/doc/HTML/index.html
205
	rm -rf /usr/share/doc/livecd
206
	rmdir /usr/share/doc/HTML
207
	rmdir /usr/share/doc
208
 
209
	echo
210
	echo "--------------------------------------------"
211
	echo "Restore folders saved in /mini:"
212
	echo "--------------------------------------------"
213
	for folder in $FOLDERS; do
214
	    echo "Restore $folder"
215
	    name=$( basename $folder )
216
	    base=${folder%$name}
217
	    mv /mini${folder} ${base}
218
	done
219
	mv /mini/usr/share/i18n/locales/* /usr/share/i18n/locales/
220
	echo "done."
221
    fi
231 beyerleu 222
 
223
    ### disable auto login
233 beyerleu 224
    echo "Disable auto login..."
231 beyerleu 225
    customize/livecd-autologin -u $LOCALUSER off >/dev/null 2>&1
233 beyerleu 226
    sed -i "/.*livecd-autologin.*/d" /etc/rc.d/init.d/runlast
231 beyerleu 227
 
1 beyerle@PS 228
fi
229
 
230
 
231
echo "--------------------------------------------"
232
echo "End of mini-livecd.sh" 
233
echo "--------------------------------------------"
234
echo