Subversion Repositories livecd

Rev

Rev 118 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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