Subversion Repositories livecd

Rev

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

Rev 23 Rev 67
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
### define RELEASE string
-
 
123
RELEASE="my"
-
 
124
[ -e /etc/redhat-release ] && RELEASE=$( cat /etc/redhat-release )
-
 
125
 
-
 
126
### write script version to /etc/livecd-release
122
### write script version to /etc/livecd-release
127
SCRIPT_VERSION=$( cat version 2>/dev/null )
123
SCRIPT_VERSION=$( cat version 2>/dev/null )
128
echo $SCRIPT_VERSION > /etc/livecd-release
124
echo $SCRIPT_VERSION > /etc/livecd-release
129
 
125
 
130
### Check for SMP kernel and set SMP variable
126
### Check for SMP kernel and set SMP variable
131
#   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!
132
#   SMP can only be one character in lenght!
128
#   SMP can only be one character in lenght!
133
SMP=""
129
SMP=""
134
[ -e /boot/vmlinuz-${KERNEL}smp ] && export SMP="s"
130
[ -e /boot/vmlinuz-${KERNEL}smp ] && export SMP="s"
135
 
131
 
136
 
132
 
137
 
133
 
138
###############################################################
134
###############################################################
139
### Build LiveCD
135
### Build LiveCD
140
###############################################################
136
###############################################################
141
 
137
 
142
### display summary
138
### display summary
143
### -----------------------------------------------------------
139
### -----------------------------------------------------------
144
 
140
 
145
echo; echo "--------------------------------------------"
141
echo; echo "--------------------------------------------"
146
if [ $DVD ]; then 
142
if [ $DVD ]; then 
147
    echo "Build of LiveDVD started"
143
    echo "Build of LiveDVD started"
148
else
144
else
149
    echo "Build of LiveCD started"
145
    echo "Build of LiveCD started"
150
fi
146
fi
151
echo "Script version:      $SCRIPT_VERSION"
147
echo "Script version:      $SCRIPT_VERSION"
152
echo "Kernel version:      $KERNEL"
148
echo "Kernel version:      $KERNEL"
153
[ $SMP ] && echo "SMP Kernel version:  ${KERNEL}smp"
149
[ $SMP ] && echo "SMP Kernel version:  ${KERNEL}smp"
154
echo "--------------------------------------------"
150
echo "--------------------------------------------"
155
 
151
 
156
[ $PSI ]  && echo "**** Build for PSI ****"
152
[ $PSI ]  && echo "**** Build for PSI ****"
157
[ "$OS_RELEASE" = "4" ]   && echo "**** Build for SL4 ****"
153
[ "$OS_RELEASE" = "4" ]   && echo "**** Build for SL4 ****"
158
[ "$OS_RELEASE" = "5" ]   && echo "**** Build for SL5 ****"
154
[ "$OS_RELEASE" = "5" ]   && echo "**** Build for SL5 ****"
159
[ $MINI ] && echo "**** Build for MINI-CD ****"
155
[ $MINI ] && echo "**** Build for MINI-CD ****"
160
echo "--------------------------------------------"
156
echo "--------------------------------------------"
161
 
157
 
162
 
158
 
163
 
159
 
164
### download livecd web page (for documentation)
160
### download livecd web page (for documentation)
165
### -----------------------------------------------------------
161
### -----------------------------------------------------------
166
echo "Try to download latest livecd documentation"
162
echo "Try to download latest livecd documentation"
167
 
163
 
168
rm -rf /tmp/doc
164
rm -rf /tmp/doc
169
mkdir -p /tmp/doc
165
mkdir -p /tmp/doc
170
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/
171
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
172
if [ -d /tmp/doc/livecd ]; then
168
if [ -d /tmp/doc/livecd ]; then
173
    echo "done."
169
    echo "done."
174
else
170
else
175
    echo "download failed - not critical ;-)"
171
    echo "download failed - not critical ;-)"
176
fi
172
fi
177
 
173
 
178
 
174
 
179
 
175
 
180
### clean up build script directory
176
### clean up build script directory
181
### -----------------------------------------------------------
177
### -----------------------------------------------------------
182
echo "--------------------------------------------"
178
echo "--------------------------------------------"
183
echo "Remove all *~ files in $( pwd )"
179
echo "Remove all *~ files in $( pwd )"
184
find . | grep "~$" | while read f; do rm -f "$f"; done
180
find . | grep "~$" | while read f; do rm -f "$f"; done
185
echo "done."
181
echo "done."
186
echo "--------------------------------------------"
182
echo "--------------------------------------------"
187
 
183
 
188
 
184
 
189
 
185
 
190
### Run customize-livecd.sh
186
### Run customize-livecd.sh
191
### -----------------------------------------------------------
187
### -----------------------------------------------------------
192
echo
188
echo
193
echo "--------------------------------------------"
189
echo "--------------------------------------------"
194
echo "Run ./customize-livecd.sh $PSI $DVD"
190
echo "Run ./customize-livecd.sh $PSI $DVD"
195
echo "--------------------------------------------"
191
echo "--------------------------------------------"
196
./customize-livecd.sh $PSI $DVD $MINI
192
./customize-livecd.sh $PSI $DVD $MINI
197
 
193
 
198
 
194
 
199
 
195
 
200
### Run mini-livecd.sh
196
### Run mini-livecd.sh
201
### -----------------------------------------------------------
197
### -----------------------------------------------------------
202
if [ $MINI ]; then
198
if [ $MINI ]; then
203
    echo "--------------------------------------------"
199
    echo "--------------------------------------------"
204
    echo "Run ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE"
200
    echo "Run ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE"
205
    echo "--------------------------------------------"
201
    echo "--------------------------------------------"
206
    ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE
202
    ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE
207
fi
203
fi
208
 
204
 
209
 
205
 
210
 
206
 
211
### Create /usr/share/doc/livecd
207
### Create /usr/share/doc/livecd
212
### -----------------------------------------------------------
208
### -----------------------------------------------------------
213
if [ -d /tmp/doc/livecd ]; then
209
if [ -d /tmp/doc/livecd ]; then
214
    echo
210
    echo
215
    echo "--------------------------------------------"
211
    echo "--------------------------------------------"
216
    echo "Create /usr/share/doc/livecd"
212
    echo "Create /usr/share/doc/livecd"
217
    echo "--------------------------------------------"
213
    echo "--------------------------------------------"
218
    mkdir -p /usr/share/doc/HTML
214
    mkdir -p /usr/share/doc/HTML
219
    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    
220
    rm -rf /usr/share/doc/livecd
216
    rm -rf /usr/share/doc/livecd
221
    cp -a /tmp/doc/livecd /usr/share/doc/
217
    cp -a /tmp/doc/livecd /usr/share/doc/
222
    echo "done."
218
    echo "done."
223
    echo
219
    echo
224
fi
220
fi
225
 
221
 
226
 
222
 
227
 
223
 
228
### Prepare files in linux-live.sl directory 
224
### Prepare files in linux-live.sl directory 
229
### -----------------------------------------------------------
225
### -----------------------------------------------------------
230
echo
226
echo
231
echo "--------------------------------------------"
227
echo "--------------------------------------------"
232
echo "cd linux-live.sl"
228
echo "cd linux-live.sl"
233
echo "--------------------------------------------"
229
echo "--------------------------------------------"
234
 
230
 
235
cd linux-live.sl
231
cd linux-live.sl
236
 
232
 
237
echo "Set kernel boot options in cd-root/isolinux.cfg"
233
echo "Set kernel boot options in cd-root/isolinux.cfg"
238
 
234
 
239
## for lable linux
235
## for lable linux
240
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
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
241
 
237
 
242
## for lable linuxsmp
238
## for lable linuxsmp
243
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
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
244
 
240
 
245
## for lable failsafe
241
## for lable failsafe
246
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
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
247
 
243
 
-
 
244
### define RELEASE string
-
 
245
[ -e /etc/redhat-release ] && RELEASE=$( cat /etc/redhat-release )
-
 
246
 
248
## Set Welcome ...
247
## Set Welcome ...
249
echo "Set 'Welcome ... to' in splash.cfg"
248
echo "Set 'Welcome ... to' in splash.cfg"
-
 
249
ARCH64=""
250
sed -i "s|DVD|CD|" cd-root/boot/splash.cfg
250
[ "$ARCH" = "x86_64" ] && ARCH64="64bit"
-
 
251
 
251
if [ $PSI ]; then
252
if [ $PSI ]; then
252
    sed -i "s|Welcome to.*|Welcome to PSI $LIVECD_OS LiveCD|" cd-root/boot/splash.cfg
253
    sed -i "s|Welcome to.*|Welcome to PSI $LIVECD_OS LiveCD ${ARCH64}|" cd-root/boot/splash.cfg
253
else
254
else
254
    sed -i "s|Welcome to.*|Welcome to $RELEASE|" cd-root/boot/splash.cfg
255
    sed -i "s|Welcome to.*|Welcome to $RELEASE ${ARCH64}|" cd-root/boot/splash.cfg
255
fi
256
fi
256
 
257
 
257
## Set LiveCD / LiveCD 64bit
258
## Set DVD or MiniCD (just to be sure)
258
sed -i "s|LiveCD 64bit|LiveCD|" cd-root/boot/splash.cfg
-
 
259
[ "$ARCH" = "x86_64" ] && sed -i "s|LiveCD|LiveCD 64bit|" cd-root/boot/splash.cfg
259
[ $DVD ]  && sed -i "s|CD|DVD|"    cd-root/boot/splash.cfg
260
 
-
 
261
## Set DVD or CD
-
 
262
[ $DVD ] && sed -i "s|CD|DVD|" cd-root/boot/splash.cfg
260
[ $MINI ] && sed -i "s|CD|MiniCD|" cd-root/boot/splash.cfg
263
 
261
 
264
 
262
 
265
 
263
 
266
### Run runme.sh
264
### Run runme.sh
267
### -----------------------------------------------------------
265
### -----------------------------------------------------------
268
echo
266
echo
269
echo "--------------------------------------------"
267
echo "--------------------------------------------"
270
echo "Run ./runme.sh"
268
echo "Run ./runme.sh"
271
echo "--------------------------------------------"
269
echo "--------------------------------------------"
272
./runme.sh
270
./runme.sh
273
 
271
 
274
 
272
 
275
 
273
 
276
### Run restore-system.sh
274
### Run restore-system.sh
277
### -----------------------------------------------------------
275
### -----------------------------------------------------------
278
echo
276
echo
279
echo "--------------------------------------------"
277
echo "--------------------------------------------"
280
echo "Now fix things to make this system bootable"
278
echo "Now fix things to make this system bootable"
281
echo "--------------------------------------------"
279
echo "--------------------------------------------"
282
cd ..
280
cd ..
283
./restore-system.sh $PSI
281
./restore-system.sh $PSI
284
 
282
 
285
 
283
 
286
 
284
 
287
### End of LiveCD build
285
### End of LiveCD build
288
### -----------------------------------------------------------
286
### -----------------------------------------------------------
289
echo "--------------------------------------------"
287
echo "--------------------------------------------"
290
echo "End of Build LiveCD" 
288
echo "End of Build LiveCD" 
291
echo "See /tmp for the ISO image"
289
echo "See /tmp for the ISO image"
292
echo "--------------------------------------------"
290
echo "--------------------------------------------"