Subversion Repositories livecd

Rev

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

Rev 183 Rev 194
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
    -psi        customize for PSI LiveCD
38
    -psi        customize for PSI LiveCD
39
    -mini       build a MINI-CD (not well tested)
39
    -mini       build a MINI-CD (not well tested)
40
    -dvd        build a LiveDVD
40
    -dvd        build a LiveDVD
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
rpm -q kernel | grep -q $KERNEL
136
rpm -q kernel | grep -q $KERNEL
137
if [ "$?" != "0" ]; then
137
if [ "$?" != "0" ]; then
138
    echo "ERROR: You don't have kernel $KERNEL installed."
138
    echo "ERROR: You don't have kernel $KERNEL installed."
139
    echo "       Please check your settings in livecd.conf"
139
    echo "       Please check your settings in livecd.conf"
140
    exit 1
140
    exit 1
141
fi
141
fi
142
 
142
 
143
### Check for SMP kernel and set SMP variable
143
### Check for SMP kernel and set SMP variable
144
#   if you change SMP="s", you have also to change isolinux.cfg!
144
#   if you change SMP="s", you have also to change isolinux.cfg!
145
#   SMP can only be one character in lenght!
145
#   SMP can only be one character in lenght!
146
SMP=""
146
SMP=""
147
[ -e /boot/vmlinuz-${KERNEL}smp ] && export SMP="s"
147
[ -e /boot/vmlinuz-${KERNEL}smp ] && export SMP="s"
148
 
148
 
149
 
149
 
150
 
150
 
151
###############################################################
151
###############################################################
152
### Build LiveCD
152
### Build LiveCD
153
###############################################################
153
###############################################################
154
 
154
 
155
### display summary
155
### display summary
156
### -----------------------------------------------------------
156
### -----------------------------------------------------------
157
 
157
 
158
echo; echo "--------------------------------------------"
158
echo; echo "--------------------------------------------"
159
[ $DVD ]                  && echo "Build of LiveDVD started"
159
[ $DVD ]                  && echo "Build of LiveDVD started"
160
[ $MINI ]                 && echo "Build of MINI LiveCD started"
160
[ $MINI ]                 && echo "Build of MINI LiveCD started"
161
[ ! $DVD ] && [ ! $MINI ] && echo "Build of LiveCD started"
161
[ ! $DVD ] && [ ! $MINI ] && echo "Build of LiveCD started"
162
echo "Script version:      $SCRIPT_VERSION"
162
echo "Script version:      $SCRIPT_VERSION"
163
echo "Kernel version:      $KERNEL"
163
echo "Kernel version:      $KERNEL"
164
[ $SMP ] && echo "SMP Kernel version:  ${KERNEL}smp"
164
[ $SMP ] && echo "SMP Kernel version:  ${KERNEL}smp"
165
echo "--------------------------------------------"
165
echo "--------------------------------------------"
166
 
166
 
167
[ $PSI ]  && echo "**** Build for PSI ****"
167
[ $PSI ]  && echo "**** Build for PSI ****"
168
[ "$OS_RELEASE" = "4" ]  && echo "**** Build for SL4 ****"
168
[ "$OS_RELEASE" = "4" ]  && echo "**** Build for SL4 ****"
169
[ "$OS_RELEASE" = "5" ]  && echo "**** Build for SL5 ****"
169
[ "$OS_RELEASE" = "5" ]  && echo "**** Build for SL5 ****"
170
echo "--------------------------------------------"
170
echo "--------------------------------------------"
171
 
171
 
172
 
172
 
173
 
173
 
174
### download livecd web page (for documentation)
174
### download livecd web page (for documentation)
175
### -----------------------------------------------------------
175
### -----------------------------------------------------------
176
echo "Try to download latest livecd documentation"
176
echo "Try to download latest livecd documentation"
177
 
177
 
178
rm -rf /tmp/doc
178
rm -rf /tmp/doc
179
mkdir -p /tmp/doc
179
mkdir -p /tmp/doc/livecd
180
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/
180
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc/livecd http://www.livecd.ethz.ch/
181
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/layout.css
181
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc/livecd http://www.livecd.ethz.ch/layout.css
182
[ -d /tmp/doc/livecd ] && echo "done." || echo "download failed - not critical ;-)"
182
[ -e /tmp/doc/livecd/layout.css ] && echo "done." || echo "download failed - not critical ;-)"
183
 
183
 
184
 
184
 
185
 
185
 
186
### Run customize-livecd.sh
186
### Run customize-livecd.sh
187
### -----------------------------------------------------------
187
### -----------------------------------------------------------
188
echo
188
echo
189
echo "--------------------------------------------"
189
echo "--------------------------------------------"
190
echo "Run ./customize-livecd.sh $PSI $DVD"
190
echo "Run ./customize-livecd.sh $PSI $DVD"
191
echo "--------------------------------------------"
191
echo "--------------------------------------------"
192
./customize-livecd.sh $PSI $DVD $MINI
192
./customize-livecd.sh $PSI $DVD $MINI
193
 
193
 
194
 
194
 
195
 
195
 
196
### Run mini-livecd.sh
196
### Run mini-livecd.sh
197
### -----------------------------------------------------------
197
### -----------------------------------------------------------
198
if [ $MINI ]; then
198
if [ $MINI ]; then
199
    echo "--------------------------------------------"
199
    echo "--------------------------------------------"
200
    echo "Run ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE"
200
    echo "Run ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE"
201
    echo "--------------------------------------------"
201
    echo "--------------------------------------------"
202
    ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE
202
    ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE
203
fi
203
fi
204
 
204
 
205
 
205
 
206
 
206
 
207
### Create /usr/share/doc/livecd
207
### Create /usr/share/doc/livecd
208
### -----------------------------------------------------------
208
### -----------------------------------------------------------
209
if [ -d /tmp/doc/livecd ]; then
209
if [ -d /tmp/doc/livecd ]; then
210
    echo
210
    echo
211
    echo "--------------------------------------------"
211
    echo "--------------------------------------------"
212
    echo "Create /usr/share/doc/livecd"
212
    echo "Create /usr/share/doc/livecd"
213
    echo "--------------------------------------------"
213
    echo "--------------------------------------------"
214
    mkdir -p /usr/share/doc/HTML
214
    mkdir -p /usr/share/doc/HTML
215
    cp -a customize/HTML/index.html /usr/share/doc/HTML/index.html    
215
    cp -a customize/HTML/index.html /usr/share/doc/HTML/index.html    
216
    rm -rf /usr/share/doc/livecd
216
    rm -rf /usr/share/doc/livecd
217
    cp -a /tmp/doc/livecd /usr/share/doc/
217
    cp -a /tmp/doc/livecd /usr/share/doc/
218
    echo "done."
218
    echo "done."
219
    echo
219
    echo
220
fi
220
fi
221
 
221
 
222
 
222
 
223
 
223
 
224
### Prepare files in linux-live.sl directory 
224
### Prepare files in linux-live.sl directory 
225
### -----------------------------------------------------------
225
### -----------------------------------------------------------
226
echo
226
echo
227
echo "--------------------------------------------"
227
echo "--------------------------------------------"
228
echo "cd linux-live.sl"
228
echo "cd linux-live.sl"
229
echo "--------------------------------------------"
229
echo "--------------------------------------------"
230
 
230
 
231
cd linux-live.sl
231
cd linux-live.sl
232
 
232
 
233
### set CHANGESFOLDER name
233
### set CHANGESFOLDER name
234
if [ "$CHANGESFOLDER" = "" ]; then CHANGESFOLDER=changes; fi
234
if [ "$CHANGESFOLDER" = "" ]; then CHANGESFOLDER=changes; fi
235
sed -i "s|^CHANGES=.*|CHANGES=\$MEMORY/$CHANGESFOLDER|" initrd/linuxrc
235
sed -i "s|^CHANGES=.*|CHANGES=\$MEMORY/$CHANGESFOLDER|" initrd/linuxrc
236
 
236
 
237
### create isolinux.cfg from isolinux.cfg.tpl
237
### create isolinux.cfg from isolinux.cfg.tpl
238
echo "Create cd-root/isolinux.cfg"
238
echo "Create cd-root/isolinux.cfg"
239
cp cd-root/isolinux.cfg.tpl cd-root/isolinux.cfg
239
cp cd-root/isolinux.cfg.tpl cd-root/isolinux.cfg
240
 
240
 
241
sed -i "s|append linux|append initrd=boot/initrd.gz init=linuxrc $BOOT_OPTIONS|" cd-root/isolinux.cfg
241
sed -i "s|append linux|append initrd=boot/initrd.gz init=linuxrc $BOOT_OPTIONS|" cd-root/isolinux.cfg
242
sed -i "s|append smp|append initrd=boot/initrd${SMP}.gz init=linuxrc $BOOT_OPTIONS|" cd-root/isolinux.cfg
242
sed -i "s|append smp|append initrd=boot/initrd${SMP}.gz init=linuxrc $BOOT_OPTIONS|" cd-root/isolinux.cfg
243
sed -i "s|append failsafe|append initrd=boot/initrd.gz init=linuxrc $BOOT_OPTIONS $FAILSAFE_BOOT_OPTIONS|" cd-root/isolinux.cfg
243
sed -i "s|append failsafe|append initrd=boot/initrd.gz init=linuxrc $BOOT_OPTIONS $FAILSAFE_BOOT_OPTIONS|" cd-root/isolinux.cfg
244
 
244
 
245
### create splash.cfg from splash.cfg.tpl
245
### create splash.cfg from splash.cfg.tpl
246
echo "Create in splash.cfg"
246
echo "Create in splash.cfg"
247
cp cd-root/boot/splash.cfg.tpl cd-root/boot/splash.cfg
247
cp cd-root/boot/splash.cfg.tpl cd-root/boot/splash.cfg
248
[ -e /etc/redhat-release ] && RELEASE=$( cat /etc/redhat-release )
248
[ -e /etc/redhat-release ] && RELEASE=$( cat /etc/redhat-release )
249
ARCH64=""
249
ARCH64=""
250
[ "$ARCH" = "x86_64" ] && ARCH64="64bit"
250
[ "$ARCH" = "x86_64" ] && ARCH64="64bit"
251
 
251
 
252
if [ $PSI ]; then
252
if [ $PSI ]; then
253
    sed -i "s|Welcome to.*|Welcome to PSI $LIVECD_OS LiveCD ${ARCH64}|" cd-root/boot/splash.cfg
253
    sed -i "s|Welcome to.*|Welcome to PSI $LIVECD_OS LiveCD ${ARCH64}|" cd-root/boot/splash.cfg
254
else
254
else
255
    sed -i "s|Welcome to.*|Welcome to $RELEASE ${ARCH64}|" cd-root/boot/splash.cfg
255
    sed -i "s|Welcome to.*|Welcome to $RELEASE ${ARCH64}|" cd-root/boot/splash.cfg
256
fi
256
fi
257
[ $DVD ]  && sed -i "s|LiveCD|LiveDVD|"    cd-root/boot/splash.cfg
257
[ $DVD ]  && sed -i "s|LiveCD|LiveDVD|"    cd-root/boot/splash.cfg
258
[ $MINI ] && sed -i "s|LiveCD|LiveMiniCD|" cd-root/boot/splash.cfg
258
[ $MINI ] && sed -i "s|LiveCD|LiveMiniCD|" cd-root/boot/splash.cfg
259
 
259
 
260
 
260
 
261
 
261
 
262
### Run runme.sh
262
### Run runme.sh
263
### -----------------------------------------------------------
263
### -----------------------------------------------------------
264
echo
264
echo
265
echo "--------------------------------------------"
265
echo "--------------------------------------------"
266
echo "Run ./runme.sh"
266
echo "Run ./runme.sh"
267
echo "--------------------------------------------"
267
echo "--------------------------------------------"
268
./runme.sh
268
./runme.sh
269
rm -f cd-root/boot/splash.cfg
269
rm -f cd-root/boot/splash.cfg
270
rm -f cd-root/isolinux.cfg
270
rm -f cd-root/isolinux.cfg
271
 
271
 
272
 
272
 
273
 
273
 
274
### Run restore-system.sh
274
### Run restore-system.sh
275
### -----------------------------------------------------------
275
### -----------------------------------------------------------
276
echo
276
echo
277
echo "--------------------------------------------"
277
echo "--------------------------------------------"
278
echo "Now fix things to make this system bootable"
278
echo "Now fix things to make this system bootable"
279
echo "--------------------------------------------"
279
echo "--------------------------------------------"
280
cd ..
280
cd ..
281
./restore-system.sh $PSI
281
./restore-system.sh $PSI
282
 
282
 
283
 
283
 
284
 
284
 
285
### End of LiveCD build
285
### End of LiveCD build
286
### -----------------------------------------------------------
286
### -----------------------------------------------------------
287
echo "--------------------------------------------"
287
echo "--------------------------------------------"
288
echo "End of Build LiveCD" 
288
echo "End of Build LiveCD" 
289
echo "See /tmp for the ISO image"
289
echo "See /tmp for the ISO image"
290
echo "--------------------------------------------"
290
echo "--------------------------------------------"