Subversion Repositories livecd

Rev

Rev 169 | Rev 181 | 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
 
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
 
125 beyerle@PS 93
### check if I run inside my directory
94
if [ ! -x $( basename $0 ) ]; then
95
    echo "Please run $( basename $0 ) within its directory"
96
    exit 1
97
fi
23 beyerle@PS 98
 
99
### source livecd.conf
100
. livecd.conf
101
 
102
### test input
103
[ ! $SL ] && usage 
104
 
125 beyerle@PS 105
### show warning, if not in chroot
118 beyerle@PS 106
mounts=$( mount 2>/dev/null | grep -v proc )
107
if [ "$mounts" != "" ]; then
119 beyerle@PS 108
    echo; echo "It seems that you do not build in chroot."
118 beyerle@PS 109
    echo -n "Do you really want to continue (y/N)? "
110
    read -n 1 key
111
    [ "$key" != "y" ] && exit
112
fi
113
 
23 beyerle@PS 114
### do not run without psi option on a PSI installation
125 beyerle@PS 115
if [ -e /etc/sysconfig/psi ] && [ ! $PSI ]; then
23 beyerle@PS 116
    echo "I guess this is a PSI installation, please use option '-psi'"; echo
1 beyerle@PS 117
    exit
118
fi
119
 
120
### add extra boot options
121
BOOT_OPTIONS="$BOOT_OPTIONS $EXTRA_BOOT_OPTIONS"
122
 
123
### add option "psi" for PSI
124
[ $PSI ] && BOOT_OPTIONS="psi $BOOT_OPTIONS"
125
 
23 beyerle@PS 126
### define ARCH
1 beyerle@PS 127
ARCH=$( /bin/arch )
128
[ "$ARCH" != "x86_64" ] && ARCH=i686
129
 
23 beyerle@PS 130
### write script version to /etc/livecd-release
131
SCRIPT_VERSION=$( cat version 2>/dev/null )
132
echo $SCRIPT_VERSION > /etc/livecd-release
1 beyerle@PS 133
 
134
### Check for SMP kernel and set SMP variable
23 beyerle@PS 135
#   if you change SMP="s", you have also to change isolinux.cfg!
136
#   SMP can only be one character in lenght!
1 beyerle@PS 137
SMP=""
23 beyerle@PS 138
[ -e /boot/vmlinuz-${KERNEL}smp ] && export SMP="s"
1 beyerle@PS 139
 
23 beyerle@PS 140
 
141
 
142
###############################################################
143
### Build LiveCD
144
###############################################################
145
 
146
### display summary
147
### -----------------------------------------------------------
148
 
149
echo; echo "--------------------------------------------"
125 beyerle@PS 150
[ $DVD ]                  && echo "Build of LiveDVD started"
151
[ $MINI ]                 && echo "Build of MINI LiveCD started"
152
[ ! $DVD ] && [ ! $MINI ] && echo "Build of LiveCD started"
23 beyerle@PS 153
echo "Script version:      $SCRIPT_VERSION"
1 beyerle@PS 154
echo "Kernel version:      $KERNEL"
155
[ $SMP ] && echo "SMP Kernel version:  ${KERNEL}smp"
156
echo "--------------------------------------------"
157
 
158
[ $PSI ]  && echo "**** Build for PSI ****"
125 beyerle@PS 159
[ "$OS_RELEASE" = "4" ]  && echo "**** Build for SL4 ****"
160
[ "$OS_RELEASE" = "5" ]  && echo "**** Build for SL5 ****"
1 beyerle@PS 161
echo "--------------------------------------------"
162
 
163
 
23 beyerle@PS 164
 
165
### download livecd web page (for documentation)
166
### -----------------------------------------------------------
1 beyerle@PS 167
echo "Try to download latest livecd documentation"
168
 
169
rm -rf /tmp/doc
170
mkdir -p /tmp/doc
171
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/
172
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/layout.css
125 beyerle@PS 173
[ -d /tmp/doc/livecd ] && echo "done." || echo "download failed - not critical ;-)"
1 beyerle@PS 174
 
175
 
23 beyerle@PS 176
 
177
### Run customize-livecd.sh
178
### -----------------------------------------------------------
1 beyerle@PS 179
echo
180
echo "--------------------------------------------"
181
echo "Run ./customize-livecd.sh $PSI $DVD"
182
echo "--------------------------------------------"
183
./customize-livecd.sh $PSI $DVD $MINI
184
 
185
 
23 beyerle@PS 186
 
187
### Run mini-livecd.sh
188
### -----------------------------------------------------------
1 beyerle@PS 189
if [ $MINI ]; then
190
    echo "--------------------------------------------"
191
    echo "Run ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE"
192
    echo "--------------------------------------------"
193
    ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE
194
fi
195
 
23 beyerle@PS 196
 
197
 
198
### Create /usr/share/doc/livecd
199
### -----------------------------------------------------------
1 beyerle@PS 200
if [ -d /tmp/doc/livecd ]; then
201
    echo
202
    echo "--------------------------------------------"
203
    echo "Create /usr/share/doc/livecd"
204
    echo "--------------------------------------------"
205
    mkdir -p /usr/share/doc/HTML
206
    cp -a customize/HTML/index.html /usr/share/doc/HTML/index.html    
207
    rm -rf /usr/share/doc/livecd
208
    cp -a /tmp/doc/livecd /usr/share/doc/
209
    echo "done."
210
    echo
211
fi
212
 
23 beyerle@PS 213
 
214
 
215
### Prepare files in linux-live.sl directory 
216
### -----------------------------------------------------------
1 beyerle@PS 217
echo
218
echo "--------------------------------------------"
219
echo "cd linux-live.sl"
220
echo "--------------------------------------------"
221
 
222
cd linux-live.sl
223
 
179 beyerle@PS 224
### set CHANGESFOLDER name
225
if [ "$CHANGESFOLDER" = "" ]; then CHANGESFOLDER=changes; fi
226
sed -i "s|^CHANGES=.*|CHANGES=\$MEMORY/$CHANGESFOLDER|" initrd/linuxrc
227
 
93 beyerle@PS 228
### create isolinux.cfg from isolinux.cfg.tpl
229
echo "Create cd-root/isolinux.cfg"
230
cp cd-root/isolinux.cfg.tpl cd-root/isolinux.cfg
23 beyerle@PS 231
 
93 beyerle@PS 232
sed -i "s|append linux|append initrd=boot/initrd.gz init=linuxrc $BOOT_OPTIONS|" cd-root/isolinux.cfg
233
sed -i "s|append smp|append initrd=boot/initrd${SMP}.gz init=linuxrc $BOOT_OPTIONS|" cd-root/isolinux.cfg
234
sed -i "s|append failsafe|append initrd=boot/initrd.gz init=linuxrc $BOOT_OPTIONS $FAILSAFE_BOOT_OPTIONS|" cd-root/isolinux.cfg
23 beyerle@PS 235
 
125 beyerle@PS 236
### create splash.cfg from splash.cfg.tpl
93 beyerle@PS 237
echo "Create in splash.cfg"
238
cp cd-root/boot/splash.cfg.tpl cd-root/boot/splash.cfg
67 beyerle@PS 239
[ -e /etc/redhat-release ] && RELEASE=$( cat /etc/redhat-release )
240
ARCH64=""
241
[ "$ARCH" = "x86_64" ] && ARCH64="64bit"
242
 
1 beyerle@PS 243
if [ $PSI ]; then
67 beyerle@PS 244
    sed -i "s|Welcome to.*|Welcome to PSI $LIVECD_OS LiveCD ${ARCH64}|" cd-root/boot/splash.cfg
1 beyerle@PS 245
else
67 beyerle@PS 246
    sed -i "s|Welcome to.*|Welcome to $RELEASE ${ARCH64}|" cd-root/boot/splash.cfg
1 beyerle@PS 247
fi
93 beyerle@PS 248
[ $DVD ]  && sed -i "s|LiveCD|LiveDVD|"    cd-root/boot/splash.cfg
249
[ $MINI ] && sed -i "s|LiveCD|LiveMiniCD|" cd-root/boot/splash.cfg
1 beyerle@PS 250
 
251
 
252
 
23 beyerle@PS 253
### Run runme.sh
254
### -----------------------------------------------------------
1 beyerle@PS 255
echo
256
echo "--------------------------------------------"
257
echo "Run ./runme.sh"
258
echo "--------------------------------------------"
259
./runme.sh
93 beyerle@PS 260
rm -f cd-root/boot/splash.cfg
261
rm -f cd-root/isolinux.cfg
1 beyerle@PS 262
 
125 beyerle@PS 263
 
264
 
23 beyerle@PS 265
### Run restore-system.sh
266
### -----------------------------------------------------------
1 beyerle@PS 267
echo
268
echo "--------------------------------------------"
269
echo "Now fix things to make this system bootable"
270
echo "--------------------------------------------"
271
cd ..
272
./restore-system.sh $PSI
273
 
274
 
23 beyerle@PS 275
 
276
### End of LiveCD build
277
### -----------------------------------------------------------
1 beyerle@PS 278
echo "--------------------------------------------"
279
echo "End of Build LiveCD" 
280
echo "See /tmp for the ISO image"
281
echo "--------------------------------------------"