Subversion Repositories livecd

Rev

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