Subversion Repositories livecd

Rev

Details | 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
136
rpm -q kernel | grep -q $KERNEL
137
if [ "$?" != "0" ]; then
138
    echo "ERROR: You don't have kernel $KERNEL installed."
139
    echo "       Please check your settings in livecd.conf"
140
    exit 1
141
fi
142
 
1 beyerle@PS 143
### Check for SMP kernel and set SMP variable
23 beyerle@PS 144
#   if you change SMP="s", you have also to change isolinux.cfg!
145
#   SMP can only be one character in lenght!
1 beyerle@PS 146
SMP=""
23 beyerle@PS 147
[ -e /boot/vmlinuz-${KERNEL}smp ] && export SMP="s"
1 beyerle@PS 148
 
23 beyerle@PS 149
 
150
 
151
###############################################################
152
### Build LiveCD
153
###############################################################
154
 
155
### display summary
156
### -----------------------------------------------------------
157
 
158
echo; echo "--------------------------------------------"
125 beyerle@PS 159
[ $DVD ]                  && echo "Build of LiveDVD started"
160
[ $MINI ]                 && echo "Build of MINI LiveCD started"
161
[ ! $DVD ] && [ ! $MINI ] && echo "Build of LiveCD started"
23 beyerle@PS 162
echo "Script version:      $SCRIPT_VERSION"
1 beyerle@PS 163
echo "Kernel version:      $KERNEL"
164
[ $SMP ] && echo "SMP Kernel version:  ${KERNEL}smp"
165
echo "--------------------------------------------"
166
 
167
[ $PSI ]  && echo "**** Build for PSI ****"
125 beyerle@PS 168
[ "$OS_RELEASE" = "4" ]  && echo "**** Build for SL4 ****"
169
[ "$OS_RELEASE" = "5" ]  && echo "**** Build for SL5 ****"
1 beyerle@PS 170
echo "--------------------------------------------"
171
 
172
 
23 beyerle@PS 173
 
174
### download livecd web page (for documentation)
175
### -----------------------------------------------------------
1 beyerle@PS 176
echo "Try to download latest livecd documentation"
177
 
178
rm -rf /tmp/doc
179
mkdir -p /tmp/doc
180
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/
181
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/layout.css
125 beyerle@PS 182
[ -d /tmp/doc/livecd ] && echo "done." || echo "download failed - not critical ;-)"
1 beyerle@PS 183
 
184
 
23 beyerle@PS 185
 
186
### Run customize-livecd.sh
187
### -----------------------------------------------------------
1 beyerle@PS 188
echo
189
echo "--------------------------------------------"
190
echo "Run ./customize-livecd.sh $PSI $DVD"
191
echo "--------------------------------------------"
192
./customize-livecd.sh $PSI $DVD $MINI
193
 
194
 
23 beyerle@PS 195
 
196
### Run mini-livecd.sh
197
### -----------------------------------------------------------
1 beyerle@PS 198
if [ $MINI ]; then
199
    echo "--------------------------------------------"
200
    echo "Run ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE"
201
    echo "--------------------------------------------"
202
    ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE
203
fi
204
 
23 beyerle@PS 205
 
206
 
207
### Create /usr/share/doc/livecd
208
### -----------------------------------------------------------
1 beyerle@PS 209
if [ -d /tmp/doc/livecd ]; then
210
    echo
211
    echo "--------------------------------------------"
212
    echo "Create /usr/share/doc/livecd"
213
    echo "--------------------------------------------"
214
    mkdir -p /usr/share/doc/HTML
215
    cp -a customize/HTML/index.html /usr/share/doc/HTML/index.html    
216
    rm -rf /usr/share/doc/livecd
217
    cp -a /tmp/doc/livecd /usr/share/doc/
218
    echo "done."
219
    echo
220
fi
221
 
23 beyerle@PS 222
 
223
 
224
### Prepare files in linux-live.sl directory 
225
### -----------------------------------------------------------
1 beyerle@PS 226
echo
227
echo "--------------------------------------------"
228
echo "cd linux-live.sl"
229
echo "--------------------------------------------"
230
 
231
cd linux-live.sl
232
 
179 beyerle@PS 233
### set CHANGESFOLDER name
234
if [ "$CHANGESFOLDER" = "" ]; then CHANGESFOLDER=changes; fi
235
sed -i "s|^CHANGES=.*|CHANGES=\$MEMORY/$CHANGESFOLDER|" initrd/linuxrc
236
 
93 beyerle@PS 237
### create isolinux.cfg from isolinux.cfg.tpl
238
echo "Create cd-root/isolinux.cfg"
239
cp cd-root/isolinux.cfg.tpl cd-root/isolinux.cfg
23 beyerle@PS 240
 
93 beyerle@PS 241
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
243
sed -i "s|append failsafe|append initrd=boot/initrd.gz init=linuxrc $BOOT_OPTIONS $FAILSAFE_BOOT_OPTIONS|" cd-root/isolinux.cfg
23 beyerle@PS 244
 
125 beyerle@PS 245
### create splash.cfg from splash.cfg.tpl
93 beyerle@PS 246
echo "Create in splash.cfg"
247
cp cd-root/boot/splash.cfg.tpl cd-root/boot/splash.cfg
67 beyerle@PS 248
[ -e /etc/redhat-release ] && RELEASE=$( cat /etc/redhat-release )
249
ARCH64=""
250
[ "$ARCH" = "x86_64" ] && ARCH64="64bit"
251
 
1 beyerle@PS 252
if [ $PSI ]; then
67 beyerle@PS 253
    sed -i "s|Welcome to.*|Welcome to PSI $LIVECD_OS LiveCD ${ARCH64}|" cd-root/boot/splash.cfg
1 beyerle@PS 254
else
67 beyerle@PS 255
    sed -i "s|Welcome to.*|Welcome to $RELEASE ${ARCH64}|" cd-root/boot/splash.cfg
1 beyerle@PS 256
fi
93 beyerle@PS 257
[ $DVD ]  && sed -i "s|LiveCD|LiveDVD|"    cd-root/boot/splash.cfg
258
[ $MINI ] && sed -i "s|LiveCD|LiveMiniCD|" cd-root/boot/splash.cfg
1 beyerle@PS 259
 
260
 
261
 
23 beyerle@PS 262
### Run runme.sh
263
### -----------------------------------------------------------
1 beyerle@PS 264
echo
265
echo "--------------------------------------------"
266
echo "Run ./runme.sh"
267
echo "--------------------------------------------"
268
./runme.sh
93 beyerle@PS 269
rm -f cd-root/boot/splash.cfg
270
rm -f cd-root/isolinux.cfg
1 beyerle@PS 271
 
125 beyerle@PS 272
 
273
 
23 beyerle@PS 274
### Run restore-system.sh
275
### -----------------------------------------------------------
1 beyerle@PS 276
echo
277
echo "--------------------------------------------"
278
echo "Now fix things to make this system bootable"
279
echo "--------------------------------------------"
280
cd ..
281
./restore-system.sh $PSI
282
 
283
 
23 beyerle@PS 284
 
285
### End of LiveCD build
286
### -----------------------------------------------------------
1 beyerle@PS 287
echo "--------------------------------------------"
288
echo "End of Build LiveCD" 
289
echo "See /tmp for the ISO image"
290
echo "--------------------------------------------"