Subversion Repositories livecd

Rev

Rev 179 | Rev 183 | 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
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;;
71
       -psi)
72
            PSI="-psi"; shift; continue;;
73
       -mini)
74
            MINI="-mini"; shift; continue;;
75
       -nomove)
76
            NOMOVE="-nomove"; shift; continue;;
77
       -rootlogin)
78
            ROOTLOGIN="-rootlogin"; shift; continue;;
79
       -dvd)
80
            DVD="-dvd"; shift; continue;;
81
       *)
23 beyerle@PS 82
            usage;;
1 beyerle@PS 83
    esac
84
 
85
done
86
 
125 beyerle@PS 87
### check if I run inside my directory
88
if [ ! -x $( basename $0 ) ]; then
181 beyerle@PS 89
    echo "ERROR: Please run $( basename $0 ) within its directory"
125 beyerle@PS 90
    exit 1
91
fi
23 beyerle@PS 92
 
93
### source livecd.conf
94
. livecd.conf
95
 
96
### test input
181 beyerle@PS 97
if [ ! $OS_RELEASE ]; then
98
    echo "ERROR: Please define OS_RELEASE in livecd.conf"
99
    exit 1
100
fi
23 beyerle@PS 101
 
125 beyerle@PS 102
### show warning, if not in chroot
118 beyerle@PS 103
mounts=$( mount 2>/dev/null | grep -v proc )
104
if [ "$mounts" != "" ]; then
119 beyerle@PS 105
    echo; echo "It seems that you do not build in chroot."
118 beyerle@PS 106
    echo -n "Do you really want to continue (y/N)? "
107
    read -n 1 key
108
    [ "$key" != "y" ] && exit
109
fi
110
 
23 beyerle@PS 111
### do not run without psi option on a PSI installation
125 beyerle@PS 112
if [ -e /etc/sysconfig/psi ] && [ ! $PSI ]; then
23 beyerle@PS 113
    echo "I guess this is a PSI installation, please use option '-psi'"; echo
1 beyerle@PS 114
    exit
115
fi
116
 
117
### add extra boot options
118
BOOT_OPTIONS="$BOOT_OPTIONS $EXTRA_BOOT_OPTIONS"
119
 
120
### add option "psi" for PSI
121
[ $PSI ] && BOOT_OPTIONS="psi $BOOT_OPTIONS"
122
 
23 beyerle@PS 123
### define ARCH
1 beyerle@PS 124
ARCH=$( /bin/arch )
125
[ "$ARCH" != "x86_64" ] && ARCH=i686
126
 
23 beyerle@PS 127
### write script version to /etc/livecd-release
128
SCRIPT_VERSION=$( cat version 2>/dev/null )
129
echo $SCRIPT_VERSION > /etc/livecd-release
1 beyerle@PS 130
 
181 beyerle@PS 131
### Check if we have the kernel, which is defined in livecd.conf
132
rpm -q kernel | grep -q $KERNEL
133
if [ "$?" != "0" ]; then
134
    echo "ERROR: You don't have kernel $KERNEL installed."
135
    echo "       Please check your settings in livecd.conf"
136
    exit 1
137
fi
138
 
1 beyerle@PS 139
### Check for SMP kernel and set SMP variable
23 beyerle@PS 140
#   if you change SMP="s", you have also to change isolinux.cfg!
141
#   SMP can only be one character in lenght!
1 beyerle@PS 142
SMP=""
23 beyerle@PS 143
[ -e /boot/vmlinuz-${KERNEL}smp ] && export SMP="s"
1 beyerle@PS 144
 
23 beyerle@PS 145
 
146
 
147
###############################################################
148
### Build LiveCD
149
###############################################################
150
 
151
### display summary
152
### -----------------------------------------------------------
153
 
154
echo; echo "--------------------------------------------"
125 beyerle@PS 155
[ $DVD ]                  && echo "Build of LiveDVD started"
156
[ $MINI ]                 && echo "Build of MINI LiveCD started"
157
[ ! $DVD ] && [ ! $MINI ] && echo "Build of LiveCD started"
23 beyerle@PS 158
echo "Script version:      $SCRIPT_VERSION"
1 beyerle@PS 159
echo "Kernel version:      $KERNEL"
160
[ $SMP ] && echo "SMP Kernel version:  ${KERNEL}smp"
161
echo "--------------------------------------------"
162
 
163
[ $PSI ]  && echo "**** Build for PSI ****"
125 beyerle@PS 164
[ "$OS_RELEASE" = "4" ]  && echo "**** Build for SL4 ****"
165
[ "$OS_RELEASE" = "5" ]  && echo "**** Build for SL5 ****"
1 beyerle@PS 166
echo "--------------------------------------------"
167
 
168
 
23 beyerle@PS 169
 
170
### download livecd web page (for documentation)
171
### -----------------------------------------------------------
1 beyerle@PS 172
echo "Try to download latest livecd documentation"
173
 
174
rm -rf /tmp/doc
175
mkdir -p /tmp/doc
176
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/
177
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/layout.css
125 beyerle@PS 178
[ -d /tmp/doc/livecd ] && echo "done." || echo "download failed - not critical ;-)"
1 beyerle@PS 179
 
180
 
23 beyerle@PS 181
 
182
### Run customize-livecd.sh
183
### -----------------------------------------------------------
1 beyerle@PS 184
echo
185
echo "--------------------------------------------"
186
echo "Run ./customize-livecd.sh $PSI $DVD"
187
echo "--------------------------------------------"
188
./customize-livecd.sh $PSI $DVD $MINI
189
 
190
 
23 beyerle@PS 191
 
192
### Run mini-livecd.sh
193
### -----------------------------------------------------------
1 beyerle@PS 194
if [ $MINI ]; then
195
    echo "--------------------------------------------"
196
    echo "Run ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE"
197
    echo "--------------------------------------------"
198
    ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE
199
fi
200
 
23 beyerle@PS 201
 
202
 
203
### Create /usr/share/doc/livecd
204
### -----------------------------------------------------------
1 beyerle@PS 205
if [ -d /tmp/doc/livecd ]; then
206
    echo
207
    echo "--------------------------------------------"
208
    echo "Create /usr/share/doc/livecd"
209
    echo "--------------------------------------------"
210
    mkdir -p /usr/share/doc/HTML
211
    cp -a customize/HTML/index.html /usr/share/doc/HTML/index.html    
212
    rm -rf /usr/share/doc/livecd
213
    cp -a /tmp/doc/livecd /usr/share/doc/
214
    echo "done."
215
    echo
216
fi
217
 
23 beyerle@PS 218
 
219
 
220
### Prepare files in linux-live.sl directory 
221
### -----------------------------------------------------------
1 beyerle@PS 222
echo
223
echo "--------------------------------------------"
224
echo "cd linux-live.sl"
225
echo "--------------------------------------------"
226
 
227
cd linux-live.sl
228
 
179 beyerle@PS 229
### set CHANGESFOLDER name
230
if [ "$CHANGESFOLDER" = "" ]; then CHANGESFOLDER=changes; fi
231
sed -i "s|^CHANGES=.*|CHANGES=\$MEMORY/$CHANGESFOLDER|" initrd/linuxrc
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
 
125 beyerle@PS 241
### create splash.cfg from splash.cfg.tpl
93 beyerle@PS 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
 
125 beyerle@PS 268
 
269
 
23 beyerle@PS 270
### Run restore-system.sh
271
### -----------------------------------------------------------
1 beyerle@PS 272
echo
273
echo "--------------------------------------------"
274
echo "Now fix things to make this system bootable"
275
echo "--------------------------------------------"
276
cd ..
277
./restore-system.sh $PSI
278
 
279
 
23 beyerle@PS 280
 
281
### End of LiveCD build
282
### -----------------------------------------------------------
1 beyerle@PS 283
echo "--------------------------------------------"
284
echo "End of Build LiveCD" 
285
echo "See /tmp for the ISO image"
286
echo "--------------------------------------------"