Subversion Repositories livecd

Rev

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

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