Subversion Repositories livecd

Rev

Rev 234 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 234 Rev 235
1
#!/bin/bash
1
#!/bin/bash
2
#
2
#
3
################################################################
3
################################################################
4
#
4
#
5
# Used to build a MINI LiveCD
5
# Used to build a MINI LiveCD
6
# - save diskspace by moving folders to /mini
6
# - save diskspace by moving folders to /mini
7
#   disable this with "-nomove" option !
7
#   disable this with "-nomove" option !
8
# - direct login to icewm as LOCALUSER
8
# - direct login to icewm as LOCALUSER
9
#   or as root (option -rootlogin)
9
#   or as root (option -rootlogin)
10
# - configure icewm
10
# - configure icewm
11
# - run "minil-livecd -restore" to restore files from /mini again
11
# - run "minil-livecd -restore" to restore files from /mini again
12
#
12
#
13
# Urs Beyerle
13
# Urs Beyerle
14
#
14
#
15
################################################################
15
################################################################
16
 
16
 
17
# source livecd.conf
17
# source livecd.conf
18
. livecd.conf
18
. livecd.conf
19
 
19
 
20
###############################################################
20
###############################################################
21
 
21
 
22
### -----------------------------------------------------------
22
### -----------------------------------------------------------
23
### List of folders (or files) to move:
23
### List of folders (or files) to move:
24
### -----------------------------------------------------------
24
### -----------------------------------------------------------
25
FOLDERS="/usr/src \
25
FOLDERS="/usr/src \
26
         /usr/share/doc \
26
         /usr/share/doc \
27
         /usr/share/info \
27
         /usr/share/info \
28
         /usr/share/anaconda \
28
         /usr/share/anaconda \
29
         /usr/share/gdm \
29
         /usr/share/gdm \
30
         /var/cache/yum \
30
         /var/cache/yum \
31
         /etc/cups/ppds.dat \
31
         /etc/cups/ppds.dat \
32
         /etc/gconf/gconf.xml.defaults \
32
         /etc/gconf/gconf.xml.defaults \
33
         /usr/X11R6/lib/X11/doc \
33
         /usr/X11R6/lib/X11/doc \
34
         /usr/share/vim/vim70/doc \
34
         /usr/share/vim/vim70/doc \
35
         /usr/share/vim/vim70/lang \
35
         /usr/share/vim/vim70/lang \
36
         /usr/share/emacs/21.4/etc/DOC-21.4.1 \
36
         /usr/share/emacs/21.4/etc/DOC-21.4.1 \
37
         /usr/share/pixmaps/nautilus \
37
         /usr/share/pixmaps/nautilus \
38
         /usr/share/cups \
38
         /usr/share/cups \
39
	 /usr/share/icons"
39
	 /usr/share/icons"
40
 
40
 
41
#        /var/lib/rpm \
41
#        /var/lib/rpm \
42
 
42
 
43
### -----------------------------------------------------------
43
### -----------------------------------------------------------
44
### locales we don't need, we keep: en, de, fr
44
### locales we don't need, we keep: en, de, fr
45
### ----------------------------------------------------------- 
45
### ----------------------------------------------------------- 
46
 
46
 
47
### /usr/share/locale
47
### /usr/share/locale
48
### ----------------------------------------------------------- 
48
### ----------------------------------------------------------- 
49
 
49
 
50
# do we restore?
50
# do we restore?
51
if [ -d /mini/usr/share/locale/zh_TW.Big5 ]; then
51
if [ -d /mini/usr/share/locale/zh_TW.Big5 ]; then
52
    MOVE_LOCALE=$( find /mini/usr/share/locale/* -maxdepth 0 -type d  \
52
    MOVE_LOCALE=$( find /mini/usr/share/locale/* -maxdepth 0 -type d  \
53
	      | while read f; do echo ${f##/mini}; done )
53
	      | while read f; do echo ${f##/mini}; done )
54
else
54
else
55
    MOVE_LOCALE=$( find /usr/share/locale/* -maxdepth 0 -type d \
55
    MOVE_LOCALE=$( find /usr/share/locale/* -maxdepth 0 -type d \
56
              | grep -v en | grep -v de | grep -v fr )
56
              | grep -v en | grep -v de | grep -v fr )
57
fi
57
fi
58
 
58
 
59
# add to FOLDERS
59
# add to FOLDERS
60
FOLDERS="$FOLDERS $MOVE_LOCALE"      
60
FOLDERS="$FOLDERS $MOVE_LOCALE"      
61
 
61
 
62
### /mini/usr/share/backgrounds/images/
62
### /mini/usr/share/backgrounds/images/
63
mv /mini/usr/share/backgrounds/images/* /usr/share/backgrounds/images/ 2>/dev/null 
63
mv /mini/usr/share/backgrounds/images/* /usr/share/backgrounds/images/ 2>/dev/null 
64
 
64
 
65
### /usr/lib/locale
65
### /usr/lib/locale
66
### ----------------------------------------------------------- 
66
### ----------------------------------------------------------- 
67
 
67
 
68
# do we restore?
68
# do we restore?
69
if [ -d /mini/usr/lib/locale/zh_TW ]; then
69
if [ -d /mini/usr/lib/locale/zh_TW ]; then
70
    MOVE_LOCALE=$( find /mini/usr/lib/locale/* -maxdepth 0 -type d  \
70
    MOVE_LOCALE=$( find /mini/usr/lib/locale/* -maxdepth 0 -type d  \
71
	      | while read f; do echo ${f##/mini}; done )
71
	      | while read f; do echo ${f##/mini}; done )
72
else
72
else
73
    MOVE_LOCALE=$( find /usr/lib/locale/* -maxdepth 0 -type d \
73
    MOVE_LOCALE=$( find /usr/lib/locale/* -maxdepth 0 -type d \
74
              | grep -v en | grep -v de | grep -v fr )
74
              | grep -v en | grep -v de | grep -v fr )
75
fi
75
fi
76
 
76
 
77
# add to FOLDERS
77
# add to FOLDERS
78
FOLDERS="$FOLDERS $MOVE_LOCALE"      
78
FOLDERS="$FOLDERS $MOVE_LOCALE"      
79
 
79
 
80
### /usr/share/i18n/locales
80
### /usr/share/i18n/locales
81
### ----------------------------------------------------------- 
81
### ----------------------------------------------------------- 
82
 
82
 
83
# do we restore?
83
# do we restore?
84
if [ -d /mini/usr/share/i18n/locales/zh_TW ]; then
84
if [ -d /mini/usr/share/i18n/locales/zh_TW ]; then
85
    MOVE_LOCALE=$( find /mini/usr/share/i18n/locales/*  -maxdepth 0 -type f \
85
    MOVE_LOCALE=$( find /mini/usr/share/i18n/locales/*  -maxdepth 0 -type f \
86
	      | while read f; do echo ${f##/mini}; done )
86
	      | while read f; do echo ${f##/mini}; done )
87
else
87
else
88
    MOVE_LOCALE=$( find /usr/share/i18n/locales/*  -maxdepth 0 -type f \
88
    MOVE_LOCALE=$( find /usr/share/i18n/locales/*  -maxdepth 0 -type f \
89
              | grep -v en | grep -v de | grep -v fr | grep -v POSIX )
89
              | grep -v en | grep -v de | grep -v fr | grep -v POSIX )
90
fi
90
fi
91
 
91
 
92
# add to FOLDERS
92
# add to FOLDERS
93
FOLDERS="$FOLDERS $MOVE_LOCALE"      
93
FOLDERS="$FOLDERS $MOVE_LOCALE"      
94
 
94
 
95
 
95
 
96
### -----------------------------------------------------------
96
### -----------------------------------------------------------
97
function usage() {
97
function usage() {
98
 
98
 
99
   ## Usage
99
   ## Usage
100
   # ----------------------------------------------------------
100
   # ----------------------------------------------------------
101
 
101
 
102
   cat <<EOF
102
   cat <<EOF
103
 
103
 
104
   Options:
104
   Options:
105
 
105
 
106
    -h:         print this screen
106
    -h:         print this screen
107
    -restore:   restores the folders saved in /mini
107
    -restore:   restores the folders saved in /mini
108
    -nomove:    do not move to /mini
108
    -nomove:    do not move to /mini
109
    -rootlogin: login directly as root and not as LOCALUSER
109
    -rootlogin: login directly as root and not as LOCALUSER
110
    -psi:       build for PSI
110
    -psi:       build for PSI
111
 
111
 
112
EOF
112
EOF
113
 
113
 
114
}
114
}
115
 
115
 
116
 
116
 
117
### -----------------------------------------------------------
117
### -----------------------------------------------------------
118
### read options from command-line
118
### read options from command-line
119
RESTORE=""
119
RESTORE=""
120
while [ $# -gt 0 ]; do
120
while [ $# -gt 0 ]; do
121
 
121
 
122
    case "$1" in
122
    case "$1" in
123
       -h)
123
       -h)
124
            usage; exit;;
124
            usage; exit;;
125
       -restore)
125
       -restore)
126
            RESTORE="-restore"; shift; continue;;
126
            RESTORE="-restore"; shift; continue;;
127
       -psi)
127
       -psi)
128
            PSI="-psi"; shift; continue;;
128
            PSI="-psi"; shift; continue;;
129
       -nomove)
129
       -nomove)
130
            NOMOVE="-nomove"; shift; continue;;
130
            NOMOVE="-nomove"; shift; continue;;
131
       -rootlogin)
131
       -rootlogin)
132
            ROOTLOGIN="-rootlogin"; shift; continue;;
132
            ROOTLOGIN="-rootlogin"; shift; continue;;
133
       *)
133
       *)
134
            usage; exit;;
134
            usage; exit;;
135
    esac
135
    esac
136
 
136
 
137
done
137
done
138
 
138
 
139
 
139
 
140
### -----------------------------------------------------------
140
### -----------------------------------------------------------
141
### LOCALUSER name?
141
### LOCALUSER name?
142
if [ $PSI ]; then 
142
if [ $PSI ]; then 
143
    LOCALUSER=l_psi
143
    LOCALUSER=l_psi
144
else
144
else
145
    LOCALUSER=sluser
145
    LOCALUSER=sluser
146
fi
146
fi
147
 
147
 
148
 
148
 
149
### -----------------------------------------------------------
149
### -----------------------------------------------------------
150
### Modifications for Mini LiveCD
150
### Modifications for Mini LiveCD
151
if [ ! $RESTORE ]; then
151
if [ ! $RESTORE ]; then
152
    
152
    
153
    if [ ! $NOMOVE ]; then
153
    if [ ! $NOMOVE ]; then
154
	echo
154
	echo
155
	echo "--------------------------------------------"
155
	echo "--------------------------------------------"
156
	echo "Save diskspace by moving folders to /mini:"
156
	echo "Save diskspace by moving folders to /mini:"
157
	echo "--------------------------------------------"
157
	echo "--------------------------------------------"
158
 
158
 
159
	mkdir -p /mini
159
	mkdir -p /mini
160
	for folder in $FOLDERS; do
160
	for folder in $FOLDERS; do
161
	    echo "Move $folder"
161
	    echo "Move $folder"
162
	    name=$( basename $folder )
162
	    name=$( basename $folder )
163
	    base=${folder%$name}
163
	    base=${folder%$name}
164
	    mkdir -p /mini/${base}
164
	    mkdir -p /mini/${base}
165
	    mv ${folder} /mini${base}
165
	    mv ${folder} /mini${base}
166
	done
166
	done
167
    fi
167
    fi
168
 
168
 
-
 
169
    ### force default runlevel equal 3, if neither xdm, kdm nor gdm is installed
-
 
170
    which xdm >/dev/null 2>&1 || which kdm >/dev/null 2>&1 || which gdm >/dev/null 2>&1
-
 
171
    if [ "$?" != "0" ]; then
-
 
172
	sed -i "s/id\:.\:initdefault/id\:3\:initdefault/" /etc/inittab
-
 
173
    fi
-
 
174
 
169
    ### enable auto login
175
    ### enable auto login
170
    echo "Enable auto login..."
176
    echo "Enable auto login..."
171
    customize/livecd-autologin -u $LOCALUSER on >/dev/null 2>&1
177
    customize/livecd-autologin -u $LOCALUSER on >/dev/null 2>&1
172
    echo "### enable auto login for user $LOCALUSER (livecd-autologin)" >> /etc/rc.d/init.d/runlast
178
    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
179
    echo "livecd-autologin -u $LOCALUSER on >/dev/null 2>&1"            >> /etc/rc.d/init.d/runlast
174
 
180
 
175
    ### run updatedb
181
    ### run updatedb
176
    echo "Run updatedb..."
182
    echo "Run updatedb..."
177
    . /etc/updatedb.conf 2>/dev/null
183
    . /etc/updatedb.conf 2>/dev/null
178
    rpm -q mlocate >/dev/null
184
    rpm -q mlocate >/dev/null
179
    if [ "$?" = "0" ]; then
185
    if [ "$?" = "0" ]; then
180
	/usr/bin/updatedb -e "/media /sfs /tmp /boot /livecd /home /net /trunk"
186
	/usr/bin/updatedb -e "/media /sfs /tmp /boot /livecd /home /net /trunk"
181
    else
187
    else
182
	/usr/bin/updatedb -e /media,/tmp,/boot,/livecd,/home,/net,/trunk
188
	/usr/bin/updatedb -e /media,/tmp,/boot,/livecd,/home,/net,/trunk
183
    fi
189
    fi
184
    echo "done."
190
    echo "done."
185
 
191
 
186
 
192
 
187
 
193
 
188
### -----------------------------------------------------------
194
### -----------------------------------------------------------
189
### Restores some modifications
195
### Restores some modifications
190
else
196
else
191
 
197
 
192
    if [ ! $NOMOVE ]; then
198
    if [ ! $NOMOVE ]; then
193
        ### remove default html page
199
        ### remove default html page
194
	rm /usr/share/doc/HTML/index.html
200
	rm /usr/share/doc/HTML/index.html
195
	rm -rf /usr/share/doc/livecd
201
	rm -rf /usr/share/doc/livecd
196
	rmdir /usr/share/doc/HTML
202
	rmdir /usr/share/doc/HTML
197
	rmdir /usr/share/doc
203
	rmdir /usr/share/doc
198
 
204
 
199
	echo
205
	echo
200
	echo "--------------------------------------------"
206
	echo "--------------------------------------------"
201
	echo "Restore folders saved in /mini:"
207
	echo "Restore folders saved in /mini:"
202
	echo "--------------------------------------------"
208
	echo "--------------------------------------------"
203
	for folder in $FOLDERS; do
209
	for folder in $FOLDERS; do
204
	    echo "Restore $folder"
210
	    echo "Restore $folder"
205
	    name=$( basename $folder )
211
	    name=$( basename $folder )
206
	    base=${folder%$name}
212
	    base=${folder%$name}
207
	    mv /mini${folder} ${base}
213
	    mv /mini${folder} ${base}
208
	done
214
	done
209
	mv /mini/usr/share/i18n/locales/* /usr/share/i18n/locales/
215
	mv /mini/usr/share/i18n/locales/* /usr/share/i18n/locales/
210
	echo "done."
216
	echo "done."
211
    fi
217
    fi
212
 
218
 
213
    ### disable auto login
219
    ### disable auto login
214
    echo "Disable auto login..."
220
    echo "Disable auto login..."
215
    customize/livecd-autologin -u $LOCALUSER off >/dev/null 2>&1
221
    customize/livecd-autologin -u $LOCALUSER off >/dev/null 2>&1
216
    sed -i "/.*livecd-autologin.*/d" /etc/rc.d/init.d/runlast
222
    sed -i "/.*livecd-autologin.*/d" /etc/rc.d/init.d/runlast
217
 
223
 
218
fi
224
fi
219
 
225
 
220
 
226
 
221
echo "--------------------------------------------"
227
echo "--------------------------------------------"
222
echo "End of mini-livecd.sh" 
228
echo "End of mini-livecd.sh" 
223
echo "--------------------------------------------"
229
echo "--------------------------------------------"
224
echo
230
echo