Subversion Repositories livecd

Rev

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