Subversion Repositories livecd

Rev

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

Rev 67 Rev 93
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
### do not run without psi option on a PSI installation
100
### do not run without psi option on a PSI installation
101
if [ -e /etc/sysconfig/cfengine ] && [ ! $PSI ]; then
101
if [ -e /etc/sysconfig/cfengine ] && [ ! $PSI ]; then
102
    echo "I guess this is a PSI installation, please use option '-psi'"; echo
102
    echo "I guess this is a PSI installation, please use option '-psi'"; echo
103
    exit
103
    exit
104
fi
104
fi
105
 
105
 
106
### check if I run inside my directory
106
### check if I run inside my directory
107
if [ ! -x $( basename $0 ) ]; then
107
if [ ! -x $( basename $0 ) ]; then
108
    echo "Please run $( basename $0 ) within its directory"
108
    echo "Please run $( basename $0 ) within its directory"
109
    exit 1
109
    exit 1
110
fi
110
fi
111
 
111
 
112
### add extra boot options
112
### add extra boot options
113
BOOT_OPTIONS="$BOOT_OPTIONS $EXTRA_BOOT_OPTIONS"
113
BOOT_OPTIONS="$BOOT_OPTIONS $EXTRA_BOOT_OPTIONS"
114
 
114
 
115
### add option "psi" for PSI
115
### add option "psi" for PSI
116
[ $PSI ] && BOOT_OPTIONS="psi $BOOT_OPTIONS"
116
[ $PSI ] && BOOT_OPTIONS="psi $BOOT_OPTIONS"
117
 
117
 
118
### define ARCH
118
### define ARCH
119
ARCH=$( /bin/arch )
119
ARCH=$( /bin/arch )
120
[ "$ARCH" != "x86_64" ] && ARCH=i686
120
[ "$ARCH" != "x86_64" ] && ARCH=i686
121
 
121
 
122
### write script version to /etc/livecd-release
122
### write script version to /etc/livecd-release
123
SCRIPT_VERSION=$( cat version 2>/dev/null )
123
SCRIPT_VERSION=$( cat version 2>/dev/null )
124
echo $SCRIPT_VERSION > /etc/livecd-release
124
echo $SCRIPT_VERSION > /etc/livecd-release
125
 
125
 
126
### Check for SMP kernel and set SMP variable
126
### Check for SMP kernel and set SMP variable
127
#   if you change SMP="s", you have also to change isolinux.cfg!
127
#   if you change SMP="s", you have also to change isolinux.cfg!
128
#   SMP can only be one character in lenght!
128
#   SMP can only be one character in lenght!
129
SMP=""
129
SMP=""
130
[ -e /boot/vmlinuz-${KERNEL}smp ] && export SMP="s"
130
[ -e /boot/vmlinuz-${KERNEL}smp ] && export SMP="s"
131
 
131
 
132
 
132
 
133
 
133
 
134
###############################################################
134
###############################################################
135
### Build LiveCD
135
### Build LiveCD
136
###############################################################
136
###############################################################
137
 
137
 
138
### display summary
138
### display summary
139
### -----------------------------------------------------------
139
### -----------------------------------------------------------
140
 
140
 
141
echo; echo "--------------------------------------------"
141
echo; echo "--------------------------------------------"
142
if [ $DVD ]; then 
142
if [ $DVD ]; then 
143
    echo "Build of LiveDVD started"
143
    echo "Build of LiveDVD started"
144
else
144
else
145
    echo "Build of LiveCD started"
145
    echo "Build of LiveCD started"
146
fi
146
fi
147
echo "Script version:      $SCRIPT_VERSION"
147
echo "Script version:      $SCRIPT_VERSION"
148
echo "Kernel version:      $KERNEL"
148
echo "Kernel version:      $KERNEL"
149
[ $SMP ] && echo "SMP Kernel version:  ${KERNEL}smp"
149
[ $SMP ] && echo "SMP Kernel version:  ${KERNEL}smp"
150
echo "--------------------------------------------"
150
echo "--------------------------------------------"
151
 
151
 
152
[ $PSI ]  && echo "**** Build for PSI ****"
152
[ $PSI ]  && echo "**** Build for PSI ****"
153
[ "$OS_RELEASE" = "4" ]   && echo "**** Build for SL4 ****"
153
[ "$OS_RELEASE" = "4" ]   && echo "**** Build for SL4 ****"
154
[ "$OS_RELEASE" = "5" ]   && echo "**** Build for SL5 ****"
154
[ "$OS_RELEASE" = "5" ]   && echo "**** Build for SL5 ****"
155
[ $MINI ] && echo "**** Build for MINI-CD ****"
155
[ $MINI ] && echo "**** Build for MINI-CD ****"
156
echo "--------------------------------------------"
156
echo "--------------------------------------------"
157
 
157
 
158
 
158
 
159
 
159
 
160
### download livecd web page (for documentation)
160
### download livecd web page (for documentation)
161
### -----------------------------------------------------------
161
### -----------------------------------------------------------
162
echo "Try to download latest livecd documentation"
162
echo "Try to download latest livecd documentation"
163
 
163
 
164
rm -rf /tmp/doc
164
rm -rf /tmp/doc
165
mkdir -p /tmp/doc
165
mkdir -p /tmp/doc
166
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/
166
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/
167
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/layout.css
167
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/layout.css
168
if [ -d /tmp/doc/livecd ]; then
168
if [ -d /tmp/doc/livecd ]; then
169
    echo "done."
169
    echo "done."
170
else
170
else
171
    echo "download failed - not critical ;-)"
171
    echo "download failed - not critical ;-)"
172
fi
172
fi
173
 
173
 
174
 
174
 
175
 
175
 
176
### clean up build script directory
176
### clean up build script directory
177
### -----------------------------------------------------------
177
### -----------------------------------------------------------
178
echo "--------------------------------------------"
178
echo "--------------------------------------------"
179
echo "Remove all *~ files in $( pwd )"
179
echo "Remove all *~ files in $( pwd )"
180
find . | grep "~$" | while read f; do rm -f "$f"; done
180
find . | grep "~$" | while read f; do rm -f "$f"; done
181
echo "done."
181
echo "done."
182
echo "--------------------------------------------"
182
echo "--------------------------------------------"
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
### create isolinux.cfg from isolinux.cfg.tpl
233
echo "Set kernel boot options in cd-root/isolinux.cfg"
234
echo "Create cd-root/isolinux.cfg"
-
 
235
cp cd-root/isolinux.cfg.tpl cd-root/isolinux.cfg
234
 
236
 
235
## for lable linux
-
 
236
sed -i "s|append l initrd=boot/initrd.gz init=linuxrc .*|append l initrd=boot/initrd.gz init=linuxrc $BOOT_OPTIONS|" cd-root/isolinux.cfg
237
sed -i "s|append linux|append initrd=boot/initrd.gz init=linuxrc $BOOT_OPTIONS|" cd-root/isolinux.cfg
237
 
-
 
238
## for lable linuxsmp
-
 
239
sed -i "s|append l initrd=boot/initrd${SMP}.gz init=linuxrc .*|append l initrd=boot/initrd${SMP}.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
240
 
-
 
241
## for lable failsafe
-
 
242
sed -i "s|append f initrd=boot/initrd.gz init=linuxrc .*|append f initrd=boot/initrd.gz init=linuxrc $BOOT_OPTIONS $FAILSAFE_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
243
 
240
 
-
 
241
### create splash.cfg from plash.cfg.tpl
244
### define RELEASE string
242
echo "Create in splash.cfg"
-
 
243
cp cd-root/boot/splash.cfg.tpl cd-root/boot/splash.cfg
245
[ -e /etc/redhat-release ] && RELEASE=$( cat /etc/redhat-release )
244
[ -e /etc/redhat-release ] && RELEASE=$( cat /etc/redhat-release )
246
 
-
 
247
## Set Welcome ...
-
 
248
echo "Set 'Welcome ... to' in splash.cfg"
-
 
249
ARCH64=""
245
ARCH64=""
250
[ "$ARCH" = "x86_64" ] && ARCH64="64bit"
246
[ "$ARCH" = "x86_64" ] && ARCH64="64bit"
251
 
247
 
252
if [ $PSI ]; then
248
if [ $PSI ]; then
253
    sed -i "s|Welcome to.*|Welcome to PSI $LIVECD_OS LiveCD ${ARCH64}|" cd-root/boot/splash.cfg
249
    sed -i "s|Welcome to.*|Welcome to PSI $LIVECD_OS LiveCD ${ARCH64}|" cd-root/boot/splash.cfg
254
else
250
else
255
    sed -i "s|Welcome to.*|Welcome to $RELEASE ${ARCH64}|" cd-root/boot/splash.cfg
251
    sed -i "s|Welcome to.*|Welcome to $RELEASE ${ARCH64}|" cd-root/boot/splash.cfg
256
fi
252
fi
257
 
-
 
258
## Set DVD or MiniCD (just to be sure)
-
 
259
[ $DVD ]  && sed -i "s|CD|DVD|"    cd-root/boot/splash.cfg
253
[ $DVD ]  && sed -i "s|LiveCD|LiveDVD|"    cd-root/boot/splash.cfg
260
[ $MINI ] && sed -i "s|CD|MiniCD|" cd-root/boot/splash.cfg
254
[ $MINI ] && sed -i "s|LiveCD|LiveMiniCD|" cd-root/boot/splash.cfg
261
 
255
 
262
 
256
 
263
 
257
 
264
### Run runme.sh
258
### Run runme.sh
265
### -----------------------------------------------------------
259
### -----------------------------------------------------------
266
echo
260
echo
267
echo "--------------------------------------------"
261
echo "--------------------------------------------"
268
echo "Run ./runme.sh"
262
echo "Run ./runme.sh"
269
echo "--------------------------------------------"
263
echo "--------------------------------------------"
270
./runme.sh
264
./runme.sh
271
 
-
 
272
 
-
 
-
 
265
rm -f cd-root/boot/splash.cfg
-
 
266
rm -f cd-root/isolinux.cfg
273
 
267
 
274
### Run restore-system.sh
268
### Run restore-system.sh
275
### -----------------------------------------------------------
269
### -----------------------------------------------------------
276
echo
270
echo
277
echo "--------------------------------------------"
271
echo "--------------------------------------------"
278
echo "Now fix things to make this system bootable"
272
echo "Now fix things to make this system bootable"
279
echo "--------------------------------------------"
273
echo "--------------------------------------------"
280
cd ..
274
cd ..
281
./restore-system.sh $PSI
275
./restore-system.sh $PSI
282
 
276
 
283
 
277
 
284
 
278
 
285
### End of LiveCD build
279
### End of LiveCD build
286
### -----------------------------------------------------------
280
### -----------------------------------------------------------
287
echo "--------------------------------------------"
281
echo "--------------------------------------------"
288
echo "End of Build LiveCD" 
282
echo "End of Build LiveCD" 
289
echo "See /tmp for the ISO image"
283
echo "See /tmp for the ISO image"
290
echo "--------------------------------------------"
284
echo "--------------------------------------------"