Subversion Repositories livecd

Rev

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

Rev 199 Rev 202
1
#!/bin/bash
1
#!/bin/bash
2
#
2
#
3
###############################################################
3
###############################################################
4
#
4
#
5
# Main script to build LiveCD
5
# Main script to build LiveCD
6
# 
6
# 
7
# will execute
7
# will execute
8
# - ./customize-livecd.sh
8
# - ./customize-livecd.sh
9
# - ./mini-livecd.sh  (if -mini set)
9
# - ./mini-livecd.sh  (if -mini set)
10
# - ./linux-live.sl/runme.sh
10
# - ./linux-live.sl/runme.sh
11
# - ./restore-system.sh
11
# - ./restore-system.sh
12
#
12
#
13
# will take the configuration from
13
# will take the configuration from
14
# - ./livecd.conf
14
# - ./livecd.conf
15
#
15
#
16
# Urs Beyerle
16
# Urs Beyerle
17
#
17
#
18
###############################################################
18
###############################################################
19
 
19
 
20
 
20
 
21
###############################################################
21
###############################################################
22
### Functions
22
### Functions
23
###############################################################
23
###############################################################
24
 
24
 
25
function usage() {
25
function usage() {
26
 
26
 
27
   ## Usage
27
   ## Usage
28
   # ----------------------------------------------------------
28
   # ----------------------------------------------------------
29
 
29
 
30
   cat <<EOF
30
   cat <<EOF
31
 
31
 
32
  Options:
32
  Options:
33
 
33
 
34
    -h,--help   print this screen
34
    -h,--help   print this screen
35
 
35
 
36
  Optional Options:
36
  Optional Options:
37
 
37
 
38
    -psi        customize for PSI LiveCD
38
    -psi        customize for PSI LiveCD
39
    -mini       build a MINI-CD (not well tested)
39
    -mini       build a MINI-CD (not well tested)
40
    -dvd        build a LiveDVD
40
    -dvd        build a LiveDVD
41
    
41
    
42
  Additionally Options for MINI-CD:
42
  Additionally Options for MINI-CD:
43
 
43
 
44
    -nomove:    do NOT move to /mini to save diskspace 
44
    -nomove:    do NOT move to /mini to save diskspace 
45
    -rootlogin: directly login as root
45
    -rootlogin: directly login as root
46
 
46
 
47
  Configuration file:
47
  Configuration file:
48
 
48
 
49
    See livecd.conf for more configuration options !!
49
    See livecd.conf for more configuration options !!
50
 
50
 
51
 
51
 
52
EOF
52
EOF
53
 
53
 
54
exit
54
exit
55
 
55
 
56
}
56
}
57
 
57
 
58
###############################################################
58
###############################################################
59
### Definitions and settings
59
### Definitions and settings
60
###############################################################
60
###############################################################
61
 
61
 
62
### read options from command-line
62
### read options from command-line
63
OPTIONS=$@
63
OPTIONS=$@
64
OS_RELEASE=""
64
OS_RELEASE=""
65
 
65
 
66
while [ $# -gt 0 ]; do
66
while [ $# -gt 0 ]; do
67
 
67
 
68
    case "$1" in
68
    case "$1" in
69
       -h)
69
       -h)
70
            usage; exit;;
70
            usage; exit;;
71
       --help)
71
       --help)
72
            usage; exit;;
72
            usage; exit;;
73
       -help)
73
       -help)
74
            usage; exit;;
74
            usage; exit;;
75
       -psi)
75
       -psi)
76
            PSI="-psi"; shift; continue;;
76
            PSI="-psi"; shift; continue;;
77
       -mini)
77
       -mini)
78
            MINI="-mini"; shift; continue;;
78
            MINI="-mini"; shift; continue;;
79
       -nomove)
79
       -nomove)
80
            NOMOVE="-nomove"; shift; continue;;
80
            NOMOVE="-nomove"; shift; continue;;
81
       -rootlogin)
81
       -rootlogin)
82
            ROOTLOGIN="-rootlogin"; shift; continue;;
82
            ROOTLOGIN="-rootlogin"; shift; continue;;
83
       -dvd)
83
       -dvd)
84
            DVD="-dvd"; shift; continue;;
84
            DVD="-dvd"; shift; continue;;
85
       *)
85
       *)
86
            usage;;
86
            usage;;
87
    esac
87
    esac
88
 
88
 
89
done
89
done
90
 
90
 
91
### check if I run inside my directory
91
### check if I run inside my directory
92
if [ ! -x $( basename $0 ) ]; then
92
if [ ! -x $( basename $0 ) ]; then
93
    echo "ERROR: Please run $( basename $0 ) within its directory"
93
    echo "ERROR: Please run $( basename $0 ) within its directory"
94
    exit 1
94
    exit 1
95
fi
95
fi
96
 
96
 
97
### source livecd.conf
97
### source livecd.conf
98
. livecd.conf
98
. livecd.conf
99
 
99
 
100
### test input
100
### test input
101
if [ ! $OS_RELEASE ]; then
101
if [ ! $OS_RELEASE ]; then
102
    echo "ERROR: Please define OS_RELEASE in livecd.conf"
102
    echo "ERROR: Please define OS_RELEASE in livecd.conf"
103
    exit 1
103
    exit 1
104
fi
104
fi
105
 
105
 
106
### show warning, if not in chroot
106
### show warning, if not in chroot
107
mounts=$( mount 2>/dev/null | grep -v proc )
107
mounts=$( mount 2>/dev/null | grep -v proc )
108
if [ "$mounts" != "" ]; then
108
if [ "$mounts" != "" ]; then
109
    echo; echo "It seems that you do not build in chroot."
109
    echo; echo "It seems that you do not build in chroot."
110
    echo -n "Do you really want to continue (y/N)? "
110
    echo -n "Do you really want to continue (y/N)? "
111
    read -n 1 key
111
    read -n 1 key
112
    [ "$key" != "y" ] && exit
112
    [ "$key" != "y" ] && exit
113
fi
113
fi
114
 
114
 
115
### do not run without psi option on a PSI installation
115
### do not run without psi option on a PSI installation
116
if [ -e /etc/sysconfig/psi ] && [ ! $PSI ]; then
116
if [ -e /etc/sysconfig/psi ] && [ ! $PSI ]; then
117
    echo "I guess this is a PSI installation, please use option '-psi'"; echo
117
    echo "I guess this is a PSI installation, please use option '-psi'"; echo
118
    exit
118
    exit
119
fi
119
fi
120
 
120
 
121
### add extra boot options
121
### add extra boot options
122
BOOT_OPTIONS="$BOOT_OPTIONS $EXTRA_BOOT_OPTIONS"
122
BOOT_OPTIONS="$BOOT_OPTIONS $EXTRA_BOOT_OPTIONS"
123
 
123
 
124
### add option "psi" for PSI
124
### add option "psi" for PSI
125
[ $PSI ] && BOOT_OPTIONS="psi $BOOT_OPTIONS"
125
[ $PSI ] && BOOT_OPTIONS="psi $BOOT_OPTIONS"
126
 
126
 
127
### define ARCH
127
### define ARCH
128
ARCH=$( /bin/arch )
128
ARCH=$( /bin/arch )
129
[ "$ARCH" != "x86_64" ] && ARCH=i686
129
[ "$ARCH" != "x86_64" ] && ARCH=i686
130
 
130
 
131
### write script version to /etc/livecd-release
131
### write script version to /etc/livecd-release
132
SCRIPT_VERSION=$( cat version 2>/dev/null )
132
SCRIPT_VERSION=$( cat version 2>/dev/null )
133
echo $SCRIPT_VERSION > /etc/livecd-release
133
echo $SCRIPT_VERSION > /etc/livecd-release
134
 
134
 
135
### Check if we have the kernel, which is defined in livecd.conf
135
### Check if we have the kernel, which is defined in livecd.conf
-
 
136
wrong_kernel=""
136
rpm -q kernel | grep -q $KERNEL
137
rpm -q kernel | grep -q $KERNEL
-
 
138
[ "$?" != "0" ] && wrong_kernel="yes"
-
 
139
ls /lib/modules/$KERNEL >/dev/null
-
 
140
[ "$?" != "0" ] && wrong_kernel="yes"
137
if [ "$?" != "0" ]; then
141
if [ "$wrong_kernel" ]; then
138
    echo "ERROR: You don't have kernel $KERNEL installed."
142
    echo "ERROR: You don't have kernel $KERNEL installed."
139
    echo "       Please check your settings in livecd.conf"
143
    echo "       Please check your settings in livecd.conf"
140
    exit 1
144
    exit 1
141
fi
145
fi
142
 
146
 
143
### Check for SMP kernel and set SMP variable
147
### Check for SMP kernel and set SMP variable
144
#   if you change SMP="s", you have also to change isolinux.cfg!
148
#   if you change SMP="s", you have also to change isolinux.cfg!
145
#   SMP can only be one character in lenght!
149
#   SMP can only be one character in lenght!
146
SMP=""
150
SMP=""
147
[ -e /boot/vmlinuz-${KERNEL}smp ] && export SMP="s"
151
[ -e /boot/vmlinuz-${KERNEL}smp ] && export SMP="s"
148
 
152
 
149
 
153
 
150
 
154
 
151
###############################################################
155
###############################################################
152
### Build LiveCD
156
### Build LiveCD
153
###############################################################
157
###############################################################
154
 
158
 
155
### display summary
159
### display summary
156
### -----------------------------------------------------------
160
### -----------------------------------------------------------
157
 
161
 
158
echo; echo "--------------------------------------------"
162
echo; echo "--------------------------------------------"
159
[ $DVD ]                  && echo "Build of LiveDVD started"
163
[ $DVD ]                  && echo "Build of LiveDVD started"
160
[ $MINI ]                 && echo "Build of MINI LiveCD started"
164
[ $MINI ]                 && echo "Build of MINI LiveCD started"
161
[ ! $DVD ] && [ ! $MINI ] && echo "Build of LiveCD started"
165
[ ! $DVD ] && [ ! $MINI ] && echo "Build of LiveCD started"
162
echo "Script version:      $SCRIPT_VERSION"
166
echo "Script version:      $SCRIPT_VERSION"
163
echo "Kernel version:      $KERNEL"
167
echo "Kernel version:      $KERNEL"
164
[ $SMP ] && echo "SMP Kernel version:  ${KERNEL}smp"
168
[ $SMP ] && echo "SMP Kernel version:  ${KERNEL}smp"
165
echo "--------------------------------------------"
169
echo "--------------------------------------------"
166
 
170
 
167
[ $PSI ]  && echo "**** Build for PSI ****"
171
[ $PSI ]  && echo "**** Build for PSI ****"
168
[ "$OS_RELEASE" = "4" ]  && echo "**** Build for SL4 ****"
172
[ "$OS_RELEASE" = "4" ]  && echo "**** Build for SL4 ****"
169
[ "$OS_RELEASE" = "5" ]  && echo "**** Build for SL5 ****"
173
[ "$OS_RELEASE" = "5" ]  && echo "**** Build for SL5 ****"
170
echo "--------------------------------------------"
174
echo "--------------------------------------------"
171
 
175
 
172
 
176
 
173
 
177
 
174
### download livecd web page (for documentation)
178
### download livecd web page (for documentation)
175
### -----------------------------------------------------------
179
### -----------------------------------------------------------
176
echo "Try to download latest livecd documentation"
180
echo "Try to download latest livecd documentation"
177
 
181
 
178
rm -rf /tmp/doc
182
rm -rf /tmp/doc
179
mkdir -p /tmp/doc/livecd
183
mkdir -p /tmp/doc/livecd
180
wget --timeout=3 --quiet -nH --mirror -X download -P /tmp/doc/livecd http://www.livecd.ethz.ch/
184
wget --timeout=3 --quiet -nH --mirror -X download -P /tmp/doc/livecd http://www.livecd.ethz.ch/
181
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc/livecd http://www.livecd.ethz.ch/layout.css
185
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc/livecd http://www.livecd.ethz.ch/layout.css
182
[ -e /tmp/doc/livecd/layout.css ] && echo "done." || echo "download failed - not critical ;-)"
186
[ -e /tmp/doc/livecd/layout.css ] && echo "done." || echo "download failed - not critical ;-)"
183
 
187
 
184
 
188
 
185
 
189
 
186
### Run customize-livecd.sh
190
### Run customize-livecd.sh
187
### -----------------------------------------------------------
191
### -----------------------------------------------------------
188
echo
192
echo
189
echo "--------------------------------------------"
193
echo "--------------------------------------------"
190
echo "Run ./customize-livecd.sh $PSI $DVD"
194
echo "Run ./customize-livecd.sh $PSI $DVD"
191
echo "--------------------------------------------"
195
echo "--------------------------------------------"
192
./customize-livecd.sh $PSI $DVD $MINI
196
./customize-livecd.sh $PSI $DVD $MINI
193
 
197
 
194
 
198
 
195
 
199
 
196
### Run mini-livecd.sh
200
### Run mini-livecd.sh
197
### -----------------------------------------------------------
201
### -----------------------------------------------------------
198
if [ $MINI ]; then
202
if [ $MINI ]; then
199
    echo "--------------------------------------------"
203
    echo "--------------------------------------------"
200
    echo "Run ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE"
204
    echo "Run ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE"
201
    echo "--------------------------------------------"
205
    echo "--------------------------------------------"
202
    ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE
206
    ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE
203
fi
207
fi
204
 
208
 
205
 
209
 
206
 
210
 
207
### Create /usr/share/doc/livecd
211
### Create /usr/share/doc/livecd
208
### -----------------------------------------------------------
212
### -----------------------------------------------------------
209
if [ -d /tmp/doc/livecd ]; then
213
if [ -d /tmp/doc/livecd ]; then
210
    echo
214
    echo
211
    echo "--------------------------------------------"
215
    echo "--------------------------------------------"
212
    echo "Create /usr/share/doc/livecd"
216
    echo "Create /usr/share/doc/livecd"
213
    echo "--------------------------------------------"
217
    echo "--------------------------------------------"
214
    mkdir -p /usr/share/doc/HTML
218
    mkdir -p /usr/share/doc/HTML
215
    cp -a customize/HTML/index.html /usr/share/doc/HTML/index.html    
219
    cp -a customize/HTML/index.html /usr/share/doc/HTML/index.html    
216
    rm -rf /usr/share/doc/livecd
220
    rm -rf /usr/share/doc/livecd
217
    cp -a /tmp/doc/livecd /usr/share/doc/
221
    cp -a /tmp/doc/livecd /usr/share/doc/
218
    echo "done."
222
    echo "done."
219
    echo
223
    echo
220
fi
224
fi
221
 
225
 
222
 
226
 
223
 
227
 
224
### Prepare files in linux-live.sl directory 
228
### Prepare files in linux-live.sl directory 
225
### -----------------------------------------------------------
229
### -----------------------------------------------------------
226
echo
230
echo
227
echo "--------------------------------------------"
231
echo "--------------------------------------------"
228
echo "cd linux-live.sl"
232
echo "cd linux-live.sl"
229
echo "--------------------------------------------"
233
echo "--------------------------------------------"
230
 
234
 
231
cd linux-live.sl
235
cd linux-live.sl
232
 
236
 
233
### set CHANGESFOLDER name
237
### set CHANGESFOLDER name
234
if [ "$CHANGESFOLDER" = "" ]; then CHANGESFOLDER=changes; fi
238
if [ "$CHANGESFOLDER" = "" ]; then CHANGESFOLDER=changes; fi
235
sed -i "s|^CHANGES=.*|CHANGES=\$MEMORY/$CHANGESFOLDER|" initrd/linuxrc
239
sed -i "s|^CHANGES=.*|CHANGES=\$MEMORY/$CHANGESFOLDER|" initrd/linuxrc
236
 
240
 
237
### create isolinux.cfg from isolinux.cfg.tpl
241
### create isolinux.cfg from isolinux.cfg.tpl
238
echo "Create cd-root/isolinux.cfg"
242
echo "Create cd-root/isolinux.cfg"
239
cp cd-root/isolinux.cfg.tpl cd-root/isolinux.cfg
243
cp cd-root/isolinux.cfg.tpl cd-root/isolinux.cfg
240
 
244
 
241
sed -i "s|append linux|append initrd=boot/initrd.gz init=linuxrc $BOOT_OPTIONS|" cd-root/isolinux.cfg
245
sed -i "s|append linux|append initrd=boot/initrd.gz init=linuxrc $BOOT_OPTIONS|" cd-root/isolinux.cfg
242
sed -i "s|append smp|append initrd=boot/initrd${SMP}.gz init=linuxrc $BOOT_OPTIONS|" cd-root/isolinux.cfg
246
sed -i "s|append smp|append initrd=boot/initrd${SMP}.gz init=linuxrc $BOOT_OPTIONS|" cd-root/isolinux.cfg
243
sed -i "s|append failsafe|append initrd=boot/initrd.gz init=linuxrc $BOOT_OPTIONS $FAILSAFE_BOOT_OPTIONS|" cd-root/isolinux.cfg
247
sed -i "s|append failsafe|append initrd=boot/initrd.gz init=linuxrc $BOOT_OPTIONS $FAILSAFE_BOOT_OPTIONS|" cd-root/isolinux.cfg
244
 
248
 
245
### create splash.cfg from splash.cfg.tpl
249
### create splash.cfg from splash.cfg.tpl
246
echo "Create in splash.cfg"
250
echo "Create in splash.cfg"
247
cp cd-root/boot/splash.cfg.tpl cd-root/boot/splash.cfg
251
cp cd-root/boot/splash.cfg.tpl cd-root/boot/splash.cfg
248
[ -e /etc/redhat-release ] && RELEASE=$( cat /etc/redhat-release )
252
[ -e /etc/redhat-release ] && RELEASE=$( cat /etc/redhat-release )
249
ARCH64=""
253
ARCH64=""
250
[ "$ARCH" = "x86_64" ] && ARCH64="64bit"
254
[ "$ARCH" = "x86_64" ] && ARCH64="64bit"
251
 
255
 
252
if [ $PSI ]; then
256
if [ $PSI ]; then
253
    sed -i "s|Welcome to.*|Welcome to PSI $LIVECD_OS LiveCD ${ARCH64}|" cd-root/boot/splash.cfg
257
    sed -i "s|Welcome to.*|Welcome to PSI $LIVECD_OS LiveCD ${ARCH64}|" cd-root/boot/splash.cfg
254
else
258
else
255
    sed -i "s|Welcome to.*|Welcome to $RELEASE ${ARCH64}|" cd-root/boot/splash.cfg
259
    sed -i "s|Welcome to.*|Welcome to $RELEASE ${ARCH64}|" cd-root/boot/splash.cfg
256
fi
260
fi
257
[ $DVD ]  && sed -i "s|LiveCD|LiveDVD|"    cd-root/boot/splash.cfg
261
[ $DVD ]  && sed -i "s|LiveCD|LiveDVD|"    cd-root/boot/splash.cfg
258
[ $MINI ] && sed -i "s|LiveCD|LiveMiniCD|" cd-root/boot/splash.cfg
262
[ $MINI ] && sed -i "s|LiveCD|LiveMiniCD|" cd-root/boot/splash.cfg
259
 
263
 
260
 
264
 
261
 
265
 
262
### Run runme.sh
266
### Run runme.sh
263
### -----------------------------------------------------------
267
### -----------------------------------------------------------
264
echo
268
echo
265
echo "--------------------------------------------"
269
echo "--------------------------------------------"
266
echo "Run ./runme.sh"
270
echo "Run ./runme.sh"
267
echo "--------------------------------------------"
271
echo "--------------------------------------------"
268
./runme.sh
272
./runme.sh
269
rm -f cd-root/boot/splash.cfg
273
rm -f cd-root/boot/splash.cfg
270
rm -f cd-root/isolinux.cfg
274
rm -f cd-root/isolinux.cfg
271
 
275
 
272
 
276
 
273
 
277
 
274
### Run restore-system.sh
278
### Run restore-system.sh
275
### -----------------------------------------------------------
279
### -----------------------------------------------------------
276
echo
280
echo
277
echo "--------------------------------------------"
281
echo "--------------------------------------------"
278
echo "Now fix things to make this system bootable"
282
echo "Now fix things to make this system bootable"
279
echo "--------------------------------------------"
283
echo "--------------------------------------------"
280
cd ..
284
cd ..
281
./restore-system.sh $PSI
285
./restore-system.sh $PSI
282
 
286
 
283
 
287
 
284
 
288
 
285
### End of LiveCD build
289
### End of LiveCD build
286
### -----------------------------------------------------------
290
### -----------------------------------------------------------
287
echo "--------------------------------------------"
291
echo "--------------------------------------------"
288
echo "End of Build LiveCD" 
292
echo "End of Build LiveCD" 
289
echo "See /tmp for the ISO image"
293
echo "See /tmp for the ISO image"
290
echo "--------------------------------------------"
294
echo "--------------------------------------------"