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
### define RELEASE string
123
RELEASE="my"
124
[ -e /etc/redhat-release ] && RELEASE=$( cat /etc/redhat-release )
1 beyerle@PS 125
 
23 beyerle@PS 126
### write script version to /etc/livecd-release
127
SCRIPT_VERSION=$( cat version 2>/dev/null )
128
echo $SCRIPT_VERSION > /etc/livecd-release
1 beyerle@PS 129
 
130
### Check for SMP kernel and set SMP variable
23 beyerle@PS 131
#   if you change SMP="s", you have also to change isolinux.cfg!
132
#   SMP can only be one character in lenght!
1 beyerle@PS 133
SMP=""
23 beyerle@PS 134
[ -e /boot/vmlinuz-${KERNEL}smp ] && export SMP="s"
1 beyerle@PS 135
 
23 beyerle@PS 136
 
137
 
138
###############################################################
139
### Build LiveCD
140
###############################################################
141
 
142
### display summary
143
### -----------------------------------------------------------
144
 
145
echo; echo "--------------------------------------------"
1 beyerle@PS 146
if [ $DVD ]; then 
147
    echo "Build of LiveDVD started"
148
else
149
    echo "Build of LiveCD started"
150
fi
23 beyerle@PS 151
echo "Script version:      $SCRIPT_VERSION"
1 beyerle@PS 152
echo "Kernel version:      $KERNEL"
153
[ $SMP ] && echo "SMP Kernel version:  ${KERNEL}smp"
154
echo "--------------------------------------------"
155
 
156
[ $PSI ]  && echo "**** Build for PSI ****"
23 beyerle@PS 157
[ "$OS_RELEASE" = "4" ]   && echo "**** Build for SL4 ****"
158
[ "$OS_RELEASE" = "5" ]   && echo "**** Build for SL5 ****"
1 beyerle@PS 159
[ $MINI ] && echo "**** Build for MINI-CD ****"
160
echo "--------------------------------------------"
161
 
162
 
23 beyerle@PS 163
 
164
### download livecd web page (for documentation)
165
### -----------------------------------------------------------
1 beyerle@PS 166
echo "Try to download latest livecd documentation"
167
 
168
rm -rf /tmp/doc
169
mkdir -p /tmp/doc
170
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/
171
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/layout.css
172
if [ -d /tmp/doc/livecd ]; then
173
    echo "done."
174
else
175
    echo "download failed - not critical ;-)"
176
fi
177
 
178
 
23 beyerle@PS 179
 
180
### clean up build script directory
181
### -----------------------------------------------------------
1 beyerle@PS 182
echo "--------------------------------------------"
183
echo "Remove all *~ files in $( pwd )"
184
find . | grep "~$" | while read f; do rm -f "$f"; done
185
echo "done."
186
echo "--------------------------------------------"
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
 
237
echo "Set kernel boot options in cd-root/isolinux.cfg"
23 beyerle@PS 238
 
239
## for lable linux
1 beyerle@PS 240
sed -i "s|append l initrd=boot/initrd.gz init=linuxrc .*|append l initrd=boot/initrd.gz init=linuxrc $BOOT_OPTIONS|" cd-root/isolinux.cfg
23 beyerle@PS 241
 
242
## for lable linuxsmp
1 beyerle@PS 243
sed -i "s|append l initrd=boot/initrd${SMP}.gz init=linuxrc .*|append l initrd=boot/initrd${SMP}.gz init=linuxrc $BOOT_OPTIONS|" cd-root/isolinux.cfg
23 beyerle@PS 244
 
245
## for lable failsafe
1 beyerle@PS 246
sed -i "s|append f initrd=boot/initrd.gz init=linuxrc .*|append f initrd=boot/initrd.gz init=linuxrc $BOOT_OPTIONS $FAILSAFE_BOOT_OPTIONS|" cd-root/isolinux.cfg
247
 
23 beyerle@PS 248
## Set Welcome ...
1 beyerle@PS 249
echo "Set 'Welcome ... to' in splash.cfg"
250
sed -i "s|DVD|CD|" cd-root/boot/splash.cfg
251
if [ $PSI ]; then
16 beyerle@PS 252
    sed -i "s|Welcome to.*|Welcome to PSI $LIVECD_OS LiveCD|" cd-root/boot/splash.cfg
1 beyerle@PS 253
else
16 beyerle@PS 254
    sed -i "s|Welcome to.*|Welcome to $RELEASE|" cd-root/boot/splash.cfg
1 beyerle@PS 255
fi
256
 
23 beyerle@PS 257
## Set LiveCD / LiveCD 64bit
1 beyerle@PS 258
sed -i "s|LiveCD 64bit|LiveCD|" cd-root/boot/splash.cfg
23 beyerle@PS 259
[ "$ARCH" = "x86_64" ] && sed -i "s|LiveCD|LiveCD 64bit|" cd-root/boot/splash.cfg
1 beyerle@PS 260
 
23 beyerle@PS 261
## Set DVD or CD
262
[ $DVD ] && sed -i "s|CD|DVD|" 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
273
 
23 beyerle@PS 274
 
275
 
276
### Run restore-system.sh
277
### -----------------------------------------------------------
1 beyerle@PS 278
echo
279
echo "--------------------------------------------"
280
echo "Now fix things to make this system bootable"
281
echo "--------------------------------------------"
282
cd ..
283
./restore-system.sh $PSI
284
 
285
 
23 beyerle@PS 286
 
287
### End of LiveCD build
288
### -----------------------------------------------------------
1 beyerle@PS 289
echo "--------------------------------------------"
290
echo "End of Build LiveCD" 
291
echo "See /tmp for the ISO image"
292
echo "--------------------------------------------"