Subversion Repositories livecd

Rev

Rev 222 | 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
 
169
    ### run updatedb
170
    echo "Run updatedb..."
94 beyerle@PS 171
    . /etc/updatedb.conf 2>/dev/null
172
    rpm -q mlocate >/dev/null
173
    if [ "$?" = "0" ]; then
174
	/usr/bin/updatedb -e "/media /sfs /tmp /boot /livecd /home /net /trunk"
175
    else
176
	/usr/bin/updatedb -e /media,/tmp,/boot,/livecd,/home,/net,/trunk
177
    fi
1 beyerle@PS 178
    echo "done."
179
 
180
    ### change init runlevel to 3
181
    sed -i "s/id\:.\:initdefault/id\:3\:initdefault/" /etc/inittab
182
 
183
    ### autologin at tty6
184
    if [ $ROOTLOGIN ]; then
185
	line="6:2345:respawn:\/sbin\/mingetty --autologin root tty6"
186
	# modify .bashrc for root
187
	grep -q "/dev/tty6" /root/.bashrc
188
	if [ "$?" = "1" ]; then
189
	    echo 'if [ "$( tty )" = "/dev/tty6" ]; then startx; fi' >> /root/.bashrc
190
	fi
191
    else
192
	line="6:2345:respawn:\/sbin\/mingetty --autologin $LOCALUSER tty6"
193
    fi
194
    sed -i "s/.*respawn.*tty6.*/$line/" /etc/inittab
33 beyerle@PS 195
 
196
    ### /etc/rc.d/init.d/login
197
    ### Provides directly login over xinit
198
    cp -a customize/login /etc/rc.d/init.d/login
199
    chmod +x /etc/rc.d/init.d/login
1 beyerle@PS 200
 
230 beyerleu 201
    ### modify /etc/rc.d/init.d/runlast: add /etc/init.d/login at the end
1 beyerle@PS 202
    RUNLAST=/etc/rc.d/init.d/runlast
203
    echo >> $RUNLAST
204
    echo "### execute /etc/init.d/login for direct login" >> $RUNLAST
205
    echo "/etc/init.d/login" >> $RUNLAST
206
    echo >> $RUNLAST
207
 
208
 
209
### -----------------------------------------------------------
210
### Restores some modifications
211
else
212
 
213
    if [ ! $NOMOVE ]; then
214
        ### remove default html page
215
	rm /usr/share/doc/HTML/index.html
216
	rm -rf /usr/share/doc/livecd
217
	rmdir /usr/share/doc/HTML
218
	rmdir /usr/share/doc
219
 
220
	echo
221
	echo "--------------------------------------------"
222
	echo "Restore folders saved in /mini:"
223
	echo "--------------------------------------------"
224
	for folder in $FOLDERS; do
225
	    echo "Restore $folder"
226
	    name=$( basename $folder )
227
	    base=${folder%$name}
228
	    mv /mini${folder} ${base}
229
	done
230
	mv /mini/usr/share/i18n/locales/* /usr/share/i18n/locales/
231
	echo "done."
232
    fi
233
fi
234
 
235
 
236
echo "--------------------------------------------"
237
echo "End of mini-livecd.sh" 
238
echo "--------------------------------------------"
239
echo