Subversion Repositories livecd

Rev

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

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