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
#
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
 
100
### do not run without psi option on a PSI installation
101
if [ -e /etc/sysconfig/cfengine ] && [ ! $PSI ]; then
102
    echo "I guess this is a PSI installation, please use option '-psi'"; echo
1 beyerle@PS 103
    exit
104
fi
105
 
106
### check if I run inside my directory
107
if [ ! -x $( basename $0 ) ]; then
108
    echo "Please run $( basename $0 ) within its directory"
109
    exit 1
110
fi
111
 
112
### add extra boot options
113
BOOT_OPTIONS="$BOOT_OPTIONS $EXTRA_BOOT_OPTIONS"
114
 
115
### add option "psi" for PSI
116
[ $PSI ] && BOOT_OPTIONS="psi $BOOT_OPTIONS"
117
 
23 beyerle@PS 118
### define ARCH
1 beyerle@PS 119
ARCH=$( /bin/arch )
120
[ "$ARCH" != "x86_64" ] && ARCH=i686
121
 
23 beyerle@PS 122
### write script version to /etc/livecd-release
123
SCRIPT_VERSION=$( cat version 2>/dev/null )
124
echo $SCRIPT_VERSION > /etc/livecd-release
1 beyerle@PS 125
 
126
### Check for SMP kernel and set SMP variable
23 beyerle@PS 127
#   if you change SMP="s", you have also to change isolinux.cfg!
128
#   SMP can only be one character in lenght!
1 beyerle@PS 129
SMP=""
23 beyerle@PS 130
[ -e /boot/vmlinuz-${KERNEL}smp ] && export SMP="s"
1 beyerle@PS 131
 
23 beyerle@PS 132
 
133
 
134
###############################################################
135
### Build LiveCD
136
###############################################################
137
 
138
### display summary
139
### -----------------------------------------------------------
140
 
141
echo; echo "--------------------------------------------"
1 beyerle@PS 142
if [ $DVD ]; then 
143
    echo "Build of LiveDVD started"
144
else
145
    echo "Build of LiveCD started"
146
fi
23 beyerle@PS 147
echo "Script version:      $SCRIPT_VERSION"
1 beyerle@PS 148
echo "Kernel version:      $KERNEL"
149
[ $SMP ] && echo "SMP Kernel version:  ${KERNEL}smp"
150
echo "--------------------------------------------"
151
 
152
[ $PSI ]  && echo "**** Build for PSI ****"
23 beyerle@PS 153
[ "$OS_RELEASE" = "4" ]   && echo "**** Build for SL4 ****"
154
[ "$OS_RELEASE" = "5" ]   && echo "**** Build for SL5 ****"
1 beyerle@PS 155
[ $MINI ] && echo "**** Build for MINI-CD ****"
156
echo "--------------------------------------------"
157
 
158
 
23 beyerle@PS 159
 
160
### download livecd web page (for documentation)
161
### -----------------------------------------------------------
1 beyerle@PS 162
echo "Try to download latest livecd documentation"
163
 
164
rm -rf /tmp/doc
165
mkdir -p /tmp/doc
166
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/
167
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/layout.css
168
if [ -d /tmp/doc/livecd ]; then
169
    echo "done."
170
else
171
    echo "download failed - not critical ;-)"
172
fi
173
 
174
 
23 beyerle@PS 175
 
176
### clean up build script directory
177
### -----------------------------------------------------------
1 beyerle@PS 178
echo "--------------------------------------------"
179
echo "Remove all *~ files in $( pwd )"
180
find . | grep "~$" | while read f; do rm -f "$f"; done
181
echo "done."
182
echo "--------------------------------------------"
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
 
93 beyerle@PS 233
### create isolinux.cfg from isolinux.cfg.tpl
234
echo "Create cd-root/isolinux.cfg"
235
cp cd-root/isolinux.cfg.tpl cd-root/isolinux.cfg
23 beyerle@PS 236
 
93 beyerle@PS 237
sed -i "s|append linux|append initrd=boot/initrd.gz init=linuxrc $BOOT_OPTIONS|" cd-root/isolinux.cfg
238
sed -i "s|append smp|append initrd=boot/initrd${SMP}.gz init=linuxrc $BOOT_OPTIONS|" cd-root/isolinux.cfg
239
sed -i "s|append failsafe|append initrd=boot/initrd.gz init=linuxrc $BOOT_OPTIONS $FAILSAFE_BOOT_OPTIONS|" cd-root/isolinux.cfg
23 beyerle@PS 240
 
93 beyerle@PS 241
### create splash.cfg from plash.cfg.tpl
242
echo "Create in splash.cfg"
243
cp cd-root/boot/splash.cfg.tpl cd-root/boot/splash.cfg
67 beyerle@PS 244
[ -e /etc/redhat-release ] && RELEASE=$( cat /etc/redhat-release )
245
ARCH64=""
246
[ "$ARCH" = "x86_64" ] && ARCH64="64bit"
247
 
1 beyerle@PS 248
if [ $PSI ]; then
67 beyerle@PS 249
    sed -i "s|Welcome to.*|Welcome to PSI $LIVECD_OS LiveCD ${ARCH64}|" cd-root/boot/splash.cfg
1 beyerle@PS 250
else
67 beyerle@PS 251
    sed -i "s|Welcome to.*|Welcome to $RELEASE ${ARCH64}|" cd-root/boot/splash.cfg
1 beyerle@PS 252
fi
93 beyerle@PS 253
[ $DVD ]  && sed -i "s|LiveCD|LiveDVD|"    cd-root/boot/splash.cfg
254
[ $MINI ] && sed -i "s|LiveCD|LiveMiniCD|" cd-root/boot/splash.cfg
1 beyerle@PS 255
 
256
 
257
 
23 beyerle@PS 258
### Run runme.sh
259
### -----------------------------------------------------------
1 beyerle@PS 260
echo
261
echo "--------------------------------------------"
262
echo "Run ./runme.sh"
263
echo "--------------------------------------------"
264
./runme.sh
93 beyerle@PS 265
rm -f cd-root/boot/splash.cfg
266
rm -f cd-root/isolinux.cfg
1 beyerle@PS 267
 
23 beyerle@PS 268
### Run restore-system.sh
269
### -----------------------------------------------------------
1 beyerle@PS 270
echo
271
echo "--------------------------------------------"
272
echo "Now fix things to make this system bootable"
273
echo "--------------------------------------------"
274
cd ..
275
./restore-system.sh $PSI
276
 
277
 
23 beyerle@PS 278
 
279
### End of LiveCD build
280
### -----------------------------------------------------------
1 beyerle@PS 281
echo "--------------------------------------------"
282
echo "End of Build LiveCD" 
283
echo "See /tmp for the ISO image"
284
echo "--------------------------------------------"