Subversion Repositories livecd

Rev

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

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