Subversion Repositories livecd

Rev

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

Rev 179 Rev 181
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          print this screen
34
    -h          print this screen
35
    -sl4        build SL4 LiveCD/DVD
-
 
36
    -sl5        build SL5 LiveCD/DVD
-
 
37
 
35
 
38
  Optional Options:
36
  Optional Options:
39
 
37
 
40
    -psi        customize for PSI LiveCD
38
    -psi        customize for PSI LiveCD
41
    -mini       build a MINI-CD (not well tested)
39
    -mini       build a MINI-CD (not well tested)
42
    -dvd        build a LiveDVD
40
    -dvd        build a LiveDVD
43
    
41
    
44
  Additionally Options for MINI-CD:
42
  Additionally Options for MINI-CD:
45
 
43
 
46
    -nomove:    do NOT move to /mini to save diskspace 
44
    -nomove:    do NOT move to /mini to save diskspace 
47
    -rootlogin: directly login as root
45
    -rootlogin: directly login as root
48
 
46
 
49
  Configuration file:
47
  Configuration file:
50
 
48
 
51
    See livecd.conf for more configuration options !!
49
    See livecd.conf for more configuration options !!
52
 
50
 
53
 
51
 
54
EOF
52
EOF
55
 
53
 
56
exit
54
exit
57
 
55
 
58
}
56
}
59
 
57
 
60
###############################################################
58
###############################################################
61
### Definitions and settings
59
### Definitions and settings
62
###############################################################
60
###############################################################
63
 
61
 
64
### read options from command-line
62
### read options from command-line
65
OPTIONS=$@
63
OPTIONS=$@
66
OS_RELEASE=""
64
OS_RELEASE=""
67
 
65
 
68
while [ $# -gt 0 ]; do
66
while [ $# -gt 0 ]; do
69
 
67
 
70
    case "$1" in
68
    case "$1" in
71
       -h)
69
       -h)
72
            usage; exit;;
70
            usage; exit;;
73
       -psi)
71
       -psi)
74
            PSI="-psi"; shift; continue;;
72
            PSI="-psi"; shift; continue;;
75
       -sl4)
-
 
76
            SL="-sl"; export OS_RELEASE=4; shift; continue;;
-
 
77
       -sl5)
-
 
78
            SL="-sl"; export OS_RELEASE=5; shift; continue;;
-
 
79
       -mini)
73
       -mini)
80
            MINI="-mini"; shift; continue;;
74
            MINI="-mini"; shift; continue;;
81
       -nomove)
75
       -nomove)
82
            NOMOVE="-nomove"; shift; continue;;
76
            NOMOVE="-nomove"; shift; continue;;
83
       -rootlogin)
77
       -rootlogin)
84
            ROOTLOGIN="-rootlogin"; shift; continue;;
78
            ROOTLOGIN="-rootlogin"; shift; continue;;
85
       -dvd)
79
       -dvd)
86
            DVD="-dvd"; shift; continue;;
80
            DVD="-dvd"; shift; continue;;
87
       *)
81
       *)
88
            usage;;
82
            usage;;
89
    esac
83
    esac
90
 
84
 
91
done
85
done
92
 
86
 
93
### check if I run inside my directory
87
### check if I run inside my directory
94
if [ ! -x $( basename $0 ) ]; then
88
if [ ! -x $( basename $0 ) ]; then
95
    echo "Please run $( basename $0 ) within its directory"
89
    echo "ERROR: Please run $( basename $0 ) within its directory"
96
    exit 1
90
    exit 1
97
fi
91
fi
98
 
92
 
99
### source livecd.conf
93
### source livecd.conf
100
. livecd.conf
94
. livecd.conf
101
 
95
 
102
### test input
96
### test input
103
[ ! $SL ] && usage 
97
if [ ! $OS_RELEASE ]; then
-
 
98
    echo "ERROR: Please define OS_RELEASE in livecd.conf"
-
 
99
    exit 1
-
 
100
fi
104
 
101
 
105
### show warning, if not in chroot
102
### show warning, if not in chroot
106
mounts=$( mount 2>/dev/null | grep -v proc )
103
mounts=$( mount 2>/dev/null | grep -v proc )
107
if [ "$mounts" != "" ]; then
104
if [ "$mounts" != "" ]; then
108
    echo; echo "It seems that you do not build in chroot."
105
    echo; echo "It seems that you do not build in chroot."
109
    echo -n "Do you really want to continue (y/N)? "
106
    echo -n "Do you really want to continue (y/N)? "
110
    read -n 1 key
107
    read -n 1 key
111
    [ "$key" != "y" ] && exit
108
    [ "$key" != "y" ] && exit
112
fi
109
fi
113
 
110
 
114
### do not run without psi option on a PSI installation
111
### do not run without psi option on a PSI installation
115
if [ -e /etc/sysconfig/psi ] && [ ! $PSI ]; then
112
if [ -e /etc/sysconfig/psi ] && [ ! $PSI ]; then
116
    echo "I guess this is a PSI installation, please use option '-psi'"; echo
113
    echo "I guess this is a PSI installation, please use option '-psi'"; echo
117
    exit
114
    exit
118
fi
115
fi
119
 
116
 
120
### add extra boot options
117
### add extra boot options
121
BOOT_OPTIONS="$BOOT_OPTIONS $EXTRA_BOOT_OPTIONS"
118
BOOT_OPTIONS="$BOOT_OPTIONS $EXTRA_BOOT_OPTIONS"
122
 
119
 
123
### add option "psi" for PSI
120
### add option "psi" for PSI
124
[ $PSI ] && BOOT_OPTIONS="psi $BOOT_OPTIONS"
121
[ $PSI ] && BOOT_OPTIONS="psi $BOOT_OPTIONS"
125
 
122
 
126
### define ARCH
123
### define ARCH
127
ARCH=$( /bin/arch )
124
ARCH=$( /bin/arch )
128
[ "$ARCH" != "x86_64" ] && ARCH=i686
125
[ "$ARCH" != "x86_64" ] && ARCH=i686
129
 
126
 
130
### write script version to /etc/livecd-release
127
### write script version to /etc/livecd-release
131
SCRIPT_VERSION=$( cat version 2>/dev/null )
128
SCRIPT_VERSION=$( cat version 2>/dev/null )
132
echo $SCRIPT_VERSION > /etc/livecd-release
129
echo $SCRIPT_VERSION > /etc/livecd-release
133
 
130
 
-
 
131
### Check if we have the kernel, which is defined in livecd.conf
-
 
132
rpm -q kernel | grep -q $KERNEL
-
 
133
if [ "$?" != "0" ]; then
-
 
134
    echo "ERROR: You don't have kernel $KERNEL installed."
-
 
135
    echo "       Please check your settings in livecd.conf"
-
 
136
    exit 1
-
 
137
fi
-
 
138
 
134
### Check for SMP kernel and set SMP variable
139
### Check for SMP kernel and set SMP variable
135
#   if you change SMP="s", you have also to change isolinux.cfg!
140
#   if you change SMP="s", you have also to change isolinux.cfg!
136
#   SMP can only be one character in lenght!
141
#   SMP can only be one character in lenght!
137
SMP=""
142
SMP=""
138
[ -e /boot/vmlinuz-${KERNEL}smp ] && export SMP="s"
143
[ -e /boot/vmlinuz-${KERNEL}smp ] && export SMP="s"
139
 
144
 
140
 
145
 
141
 
146
 
142
###############################################################
147
###############################################################
143
### Build LiveCD
148
### Build LiveCD
144
###############################################################
149
###############################################################
145
 
150
 
146
### display summary
151
### display summary
147
### -----------------------------------------------------------
152
### -----------------------------------------------------------
148
 
153
 
149
echo; echo "--------------------------------------------"
154
echo; echo "--------------------------------------------"
150
[ $DVD ]                  && echo "Build of LiveDVD started"
155
[ $DVD ]                  && echo "Build of LiveDVD started"
151
[ $MINI ]                 && echo "Build of MINI LiveCD started"
156
[ $MINI ]                 && echo "Build of MINI LiveCD started"
152
[ ! $DVD ] && [ ! $MINI ] && echo "Build of LiveCD started"
157
[ ! $DVD ] && [ ! $MINI ] && echo "Build of LiveCD started"
153
echo "Script version:      $SCRIPT_VERSION"
158
echo "Script version:      $SCRIPT_VERSION"
154
echo "Kernel version:      $KERNEL"
159
echo "Kernel version:      $KERNEL"
155
[ $SMP ] && echo "SMP Kernel version:  ${KERNEL}smp"
160
[ $SMP ] && echo "SMP Kernel version:  ${KERNEL}smp"
156
echo "--------------------------------------------"
161
echo "--------------------------------------------"
157
 
162
 
158
[ $PSI ]  && echo "**** Build for PSI ****"
163
[ $PSI ]  && echo "**** Build for PSI ****"
159
[ "$OS_RELEASE" = "4" ]  && echo "**** Build for SL4 ****"
164
[ "$OS_RELEASE" = "4" ]  && echo "**** Build for SL4 ****"
160
[ "$OS_RELEASE" = "5" ]  && echo "**** Build for SL5 ****"
165
[ "$OS_RELEASE" = "5" ]  && echo "**** Build for SL5 ****"
161
echo "--------------------------------------------"
166
echo "--------------------------------------------"
162
 
167
 
163
 
168
 
164
 
169
 
165
### download livecd web page (for documentation)
170
### download livecd web page (for documentation)
166
### -----------------------------------------------------------
171
### -----------------------------------------------------------
167
echo "Try to download latest livecd documentation"
172
echo "Try to download latest livecd documentation"
168
 
173
 
169
rm -rf /tmp/doc
174
rm -rf /tmp/doc
170
mkdir -p /tmp/doc
175
mkdir -p /tmp/doc
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/
172
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/layout.css
177
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 ;-)"
178
[ -d /tmp/doc/livecd ] && echo "done." || echo "download failed - not critical ;-)"
174
 
179
 
175
 
180
 
176
 
181
 
177
### Run customize-livecd.sh
182
### Run customize-livecd.sh
178
### -----------------------------------------------------------
183
### -----------------------------------------------------------
179
echo
184
echo
180
echo "--------------------------------------------"
185
echo "--------------------------------------------"
181
echo "Run ./customize-livecd.sh $PSI $DVD"
186
echo "Run ./customize-livecd.sh $PSI $DVD"
182
echo "--------------------------------------------"
187
echo "--------------------------------------------"
183
./customize-livecd.sh $PSI $DVD $MINI
188
./customize-livecd.sh $PSI $DVD $MINI
184
 
189
 
185
 
190
 
186
 
191
 
187
### Run mini-livecd.sh
192
### Run mini-livecd.sh
188
### -----------------------------------------------------------
193
### -----------------------------------------------------------
189
if [ $MINI ]; then
194
if [ $MINI ]; then
190
    echo "--------------------------------------------"
195
    echo "--------------------------------------------"
191
    echo "Run ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE"
196
    echo "Run ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE"
192
    echo "--------------------------------------------"
197
    echo "--------------------------------------------"
193
    ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE
198
    ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE
194
fi
199
fi
195
 
200
 
196
 
201
 
197
 
202
 
198
### Create /usr/share/doc/livecd
203
### Create /usr/share/doc/livecd
199
### -----------------------------------------------------------
204
### -----------------------------------------------------------
200
if [ -d /tmp/doc/livecd ]; then
205
if [ -d /tmp/doc/livecd ]; then
201
    echo
206
    echo
202
    echo "--------------------------------------------"
207
    echo "--------------------------------------------"
203
    echo "Create /usr/share/doc/livecd"
208
    echo "Create /usr/share/doc/livecd"
204
    echo "--------------------------------------------"
209
    echo "--------------------------------------------"
205
    mkdir -p /usr/share/doc/HTML
210
    mkdir -p /usr/share/doc/HTML
206
    cp -a customize/HTML/index.html /usr/share/doc/HTML/index.html    
211
    cp -a customize/HTML/index.html /usr/share/doc/HTML/index.html    
207
    rm -rf /usr/share/doc/livecd
212
    rm -rf /usr/share/doc/livecd
208
    cp -a /tmp/doc/livecd /usr/share/doc/
213
    cp -a /tmp/doc/livecd /usr/share/doc/
209
    echo "done."
214
    echo "done."
210
    echo
215
    echo
211
fi
216
fi
212
 
217
 
213
 
218
 
214
 
219
 
215
### Prepare files in linux-live.sl directory 
220
### Prepare files in linux-live.sl directory 
216
### -----------------------------------------------------------
221
### -----------------------------------------------------------
217
echo
222
echo
218
echo "--------------------------------------------"
223
echo "--------------------------------------------"
219
echo "cd linux-live.sl"
224
echo "cd linux-live.sl"
220
echo "--------------------------------------------"
225
echo "--------------------------------------------"
221
 
226
 
222
cd linux-live.sl
227
cd linux-live.sl
223
 
228
 
224
### set CHANGESFOLDER name
229
### set CHANGESFOLDER name
225
if [ "$CHANGESFOLDER" = "" ]; then CHANGESFOLDER=changes; fi
230
if [ "$CHANGESFOLDER" = "" ]; then CHANGESFOLDER=changes; fi
226
sed -i "s|^CHANGES=.*|CHANGES=\$MEMORY/$CHANGESFOLDER|" initrd/linuxrc
231
sed -i "s|^CHANGES=.*|CHANGES=\$MEMORY/$CHANGESFOLDER|" initrd/linuxrc
227
 
232
 
228
### create isolinux.cfg from isolinux.cfg.tpl
233
### create isolinux.cfg from isolinux.cfg.tpl
229
echo "Create cd-root/isolinux.cfg"
234
echo "Create cd-root/isolinux.cfg"
230
cp cd-root/isolinux.cfg.tpl cd-root/isolinux.cfg
235
cp cd-root/isolinux.cfg.tpl cd-root/isolinux.cfg
231
 
236
 
232
sed -i "s|append linux|append 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
233
sed -i "s|append smp|append 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
234
sed -i "s|append failsafe|append 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
235
 
240
 
236
### create splash.cfg from splash.cfg.tpl
241
### create splash.cfg from splash.cfg.tpl
237
echo "Create in splash.cfg"
242
echo "Create in splash.cfg"
238
cp cd-root/boot/splash.cfg.tpl cd-root/boot/splash.cfg
243
cp cd-root/boot/splash.cfg.tpl cd-root/boot/splash.cfg
239
[ -e /etc/redhat-release ] && RELEASE=$( cat /etc/redhat-release )
244
[ -e /etc/redhat-release ] && RELEASE=$( cat /etc/redhat-release )
240
ARCH64=""
245
ARCH64=""
241
[ "$ARCH" = "x86_64" ] && ARCH64="64bit"
246
[ "$ARCH" = "x86_64" ] && ARCH64="64bit"
242
 
247
 
243
if [ $PSI ]; then
248
if [ $PSI ]; then
244
    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
245
else
250
else
246
    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
247
fi
252
fi
248
[ $DVD ]  && sed -i "s|LiveCD|LiveDVD|"    cd-root/boot/splash.cfg
253
[ $DVD ]  && sed -i "s|LiveCD|LiveDVD|"    cd-root/boot/splash.cfg
249
[ $MINI ] && sed -i "s|LiveCD|LiveMiniCD|" cd-root/boot/splash.cfg
254
[ $MINI ] && sed -i "s|LiveCD|LiveMiniCD|" cd-root/boot/splash.cfg
250
 
255
 
251
 
256
 
252
 
257
 
253
### Run runme.sh
258
### Run runme.sh
254
### -----------------------------------------------------------
259
### -----------------------------------------------------------
255
echo
260
echo
256
echo "--------------------------------------------"
261
echo "--------------------------------------------"
257
echo "Run ./runme.sh"
262
echo "Run ./runme.sh"
258
echo "--------------------------------------------"
263
echo "--------------------------------------------"
259
./runme.sh
264
./runme.sh
260
rm -f cd-root/boot/splash.cfg
265
rm -f cd-root/boot/splash.cfg
261
rm -f cd-root/isolinux.cfg
266
rm -f cd-root/isolinux.cfg
262
 
267
 
263
 
268
 
264
 
269
 
265
### Run restore-system.sh
270
### Run restore-system.sh
266
### -----------------------------------------------------------
271
### -----------------------------------------------------------
267
echo
272
echo
268
echo "--------------------------------------------"
273
echo "--------------------------------------------"
269
echo "Now fix things to make this system bootable"
274
echo "Now fix things to make this system bootable"
270
echo "--------------------------------------------"
275
echo "--------------------------------------------"
271
cd ..
276
cd ..
272
./restore-system.sh $PSI
277
./restore-system.sh $PSI
273
 
278
 
274
 
279
 
275
 
280
 
276
### End of LiveCD build
281
### End of LiveCD build
277
### -----------------------------------------------------------
282
### -----------------------------------------------------------
278
echo "--------------------------------------------"
283
echo "--------------------------------------------"
279
echo "End of Build LiveCD" 
284
echo "End of Build LiveCD" 
280
echo "See /tmp for the ISO image"
285
echo "See /tmp for the ISO image"
281
echo "--------------------------------------------"
286
echo "--------------------------------------------"