Subversion Repositories livecd

Rev

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

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