Subversion Repositories livecd

Rev

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