Subversion Repositories livecd

Rev

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

Rev 7 Rev 9
1
#!/bin/bash
1
#!/bin/bash
2
#
2
#
3
###############################################################
3
###############################################################
4
#
4
#
5
# This will build the CD iso image in /tmp
5
# This will build the CD iso image in /tmp
6
# 
6
# 
7
# it will execute:
7
# it will execute:
8
# - ./customize-livecd.sh
8
# - ./customize-livecd.sh
9
# - ./runme.sh
9
# - ./runme.sh
10
# - ./restore-system.sh
10
# - ./restore-system.sh
11
#
11
#
12
# will take the configuration from
12
# will take the configuration from
13
# - ./livecd.conf
13
# - ./livecd.conf
14
#
14
#
15
# Urs Beyerle, PSI
15
# Urs Beyerle, PSI
16
#
16
#
17
###############################################################
17
###############################################################
18
 
18
 
19
# source livecd.conf
19
# source livecd.conf
20
. livecd.conf
20
. livecd.conf
21
 
21
 
22
###############################################################
22
###############################################################
23
 
23
 
24
function usage() {
24
function usage() {
25
 
25
 
26
   ## Usage
26
   ## Usage
27
   # ----------------------------------------------------------
27
   # ----------------------------------------------------------
28
 
28
 
29
   cat <<EOF
29
   cat <<EOF
30
 
30
 
31
  Options:
31
   Options:
32
 
32
 
33
    -h:         print this screen
33
    -h:         print this screen
34
    -psi:       customize for PSI Live CD
34
    -psi:       customize for PSI Live CD
35
    -sl:        customize for SL Live CD
35
    -sl:        customize for SL Live CD
36
 
36
 
37
  Optional Options:
37
   Optional Options:
38
 
38
 
39
    -mini:      build a MINI-CD (not well tested)
39
    -mini:      build a MINI-CD ROM
40
    -dvd:       build a Live DVD
40
    -dvd:       build a Live DVD
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:
-
 
48
 
-
 
49
    See livecd.conf for more configuration options !!
-
 
50
 
-
 
51
 
47
 
52
EOF
48
EOF
53
 
49
 
54
}
50
}
55
 
51
 
56
### read options from command-line
52
### read options from command-line
57
PSI=""
53
PSI=""
58
OPTIONS=$@
54
OPTIONS=$@
59
 
55
 
60
while [ $# -gt 0 ]; do
56
while [ $# -gt 0 ]; do
61
 
57
 
62
    case "$1" in
58
    case "$1" in
63
       -h)
59
       -h)
64
            usage; exit;;
60
            usage; exit;;
65
       -psi)
61
       -psi)
66
            PSI="-psi"; shift; continue;;
62
            PSI="-psi"; shift; continue;;
67
       -sl)
63
       -sl)
68
            SL="-sl"; shift; continue;;
64
            SL="-sl"; shift; continue;;
69
       -mini)
65
       -mini)
70
            MINI="-mini"; shift; continue;;
66
            MINI="-mini"; shift; continue;;
71
       -nomove)
67
       -nomove)
72
            NOMOVE="-nomove"; shift; continue;;
68
            NOMOVE="-nomove"; shift; continue;;
73
       -rootlogin)
69
       -rootlogin)
74
            ROOTLOGIN="-rootlogin"; shift; continue;;
70
            ROOTLOGIN="-rootlogin"; shift; continue;;
75
       -dvd)
71
       -dvd)
76
            DVD="-dvd"; shift; continue;;
72
            DVD="-dvd"; shift; continue;;
77
       *)
73
       *)
78
            usage; exit;;
74
            usage; exit;;
79
    esac
75
    esac
80
 
76
 
81
done
77
done
82
 
78
 
83
### only build for SL or PSI
79
### only build for SL or PSI
84
if [ ! $PSI ] && [ ! $SL ]; then
80
if [ ! $PSI ] && [ ! $SL ]; then
85
    usage 
81
    usage 
86
    exit
82
    exit
87
fi
83
fi
88
 
84
 
89
### check if I run inside my directory
85
### check if I run inside my directory
90
if [ ! -x $( basename $0 ) ]; then
86
if [ ! -x $( basename $0 ) ]; then
91
    echo "Please run $( basename $0 ) within its directory"
87
    echo "Please run $( basename $0 ) within its directory"
92
    exit 1
88
    exit 1
93
fi
89
fi
94
 
90
 
95
### add extra boot options
91
### add extra boot options
96
BOOT_OPTIONS="$BOOT_OPTIONS $EXTRA_BOOT_OPTIONS"
92
BOOT_OPTIONS="$BOOT_OPTIONS $EXTRA_BOOT_OPTIONS"
97
 
93
 
98
### add option "psi" for PSI
94
### add option "psi" for PSI
99
[ $PSI ] && BOOT_OPTIONS="psi $BOOT_OPTIONS"
95
[ $PSI ] && BOOT_OPTIONS="psi $BOOT_OPTIONS"
100
 
96
 
101
ARCH=$( /bin/arch )
97
ARCH=$( /bin/arch )
102
[ "$ARCH" != "x86_64" ] && ARCH=i686
98
[ "$ARCH" != "x86_64" ] && ARCH=i686
103
 
99
 
104
if [ -e /etc/redhat-release ]; then
100
if [ -e /etc/redhat-release ]; then
105
    RELEASE=$( cat /etc/redhat-release )
101
    RELEASE=$( cat /etc/redhat-release )
106
else
102
else
107
    RELEASE="my"
103
    RELEASE="my"
108
fi
104
fi
109
 
105
 
110
### write my version to /etc/livecd-release
106
### write my version to /etc/livecd-release
-
 
107
my_pwd=$( pwd )
111
my_version=$( cat version 2>/dev/null )
108
my_version=${my_pwd##*/}
112
echo $my_version > /etc/livecd-release
109
echo $my_version > /etc/livecd-release
113
 
110
 
114
### Check for SMP kernel and set SMP variable
111
### Check for SMP kernel and set SMP variable
115
SMP=""
112
SMP=""
116
if [ -e /boot/vmlinuz-${KERNEL}smp ]; then
113
if [ -e /boot/vmlinuz-${KERNEL}smp ]; then
117
    # if you change SMP="s", you have also to change isolinux.cfg!
114
    # if you change SMP="s", you have also to change isolinux.cfg!
118
    # SMP can only be one character in lenght!
115
    # SMP can only be one character in lenght!
119
    export SMP="s"
116
    export SMP="s"
120
fi
117
fi
121
 
118
 
122
### start
119
### start
123
echo
120
echo
124
echo "--------------------------------------------"
121
echo "--------------------------------------------"
125
if [ $DVD ]; then 
122
if [ $DVD ]; then 
126
    echo "Build of LiveDVD started"
123
    echo "Build of LiveDVD started"
127
else
124
else
128
    echo "Build of LiveCD started"
125
    echo "Build of LiveCD started"
129
fi
126
fi
130
echo "Script version:      $my_version"
127
echo "Script version:      $my_version"
131
echo "Kernel version:      $KERNEL"
128
echo "Kernel version:      $KERNEL"
132
[ $SMP ] && echo "SMP Kernel version:  ${KERNEL}smp"
129
[ $SMP ] && echo "SMP Kernel version:  ${KERNEL}smp"
133
echo "--------------------------------------------"
130
echo "--------------------------------------------"
134
 
131
 
135
[ $PSI ]  && echo "**** Build for PSI ****"
132
[ $PSI ]  && echo "**** Build for PSI ****"
136
[ $SL ]   && echo "**** Build for SL ****"
133
[ $SL ]   && echo "**** Build for SL ****"
137
[ $MINI ] && echo "**** Build for MINI-CD ****"
134
[ $MINI ] && echo "**** Build for MINI-CD ****"
138
echo "--------------------------------------------"
135
echo "--------------------------------------------"
139
 
136
 
140
 
137
 
141
# download livecd web page (for documentation)
138
# download livecd web page (for documentation)
142
echo "Try to download latest livecd documentation"
139
echo "Try to download latest livecd documentation"
143
 
140
 
144
rm -rf /tmp/doc
141
rm -rf /tmp/doc
145
mkdir -p /tmp/doc
142
mkdir -p /tmp/doc
146
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/
143
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/
147
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/layout.css
144
wget --timeout=3 --quiet -nH --mirror -P /tmp/doc http://linux.web.psi.ch/livecd/layout.css
148
if [ -d /tmp/doc/livecd ]; then
145
if [ -d /tmp/doc/livecd ]; then
149
    echo "done."
146
    echo "done."
150
else
147
else
151
    echo "download failed - not critical ;-)"
148
    echo "download failed - not critical ;-)"
152
fi
149
fi
153
 
150
 
154
 
151
 
155
# clean up build script directory
152
# clean up build script directory
156
echo "--------------------------------------------"
153
echo "--------------------------------------------"
157
echo "Remove all *~ files in $( pwd )"
154
echo "Remove all *~ files in $( pwd )"
158
find . | grep "~$" | while read f; do rm -f "$f"; done
155
find . | grep "~$" | while read f; do rm -f "$f"; done
159
echo "done."
156
echo "done."
160
echo "--------------------------------------------"
157
echo "--------------------------------------------"
161
 
158
 
162
 
159
 
163
echo
160
echo
164
echo "--------------------------------------------"
161
echo "--------------------------------------------"
165
echo "Run ./customize-livecd.sh $PSI $DVD"
162
echo "Run ./customize-livecd.sh $PSI $DVD"
166
echo "--------------------------------------------"
163
echo "--------------------------------------------"
167
./customize-livecd.sh $PSI $DVD $MINI
164
./customize-livecd.sh $PSI $DVD $MINI
168
 
165
 
169
 
166
 
170
if [ $MINI ]; then
167
if [ $MINI ]; then
171
    echo "--------------------------------------------"
168
    echo "--------------------------------------------"
172
    echo "Run ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE"
169
    echo "Run ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE"
173
    echo "--------------------------------------------"
170
    echo "--------------------------------------------"
174
    ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE
171
    ./mini-livecd.sh $PSI $ROOTLOGIN $NOMOVE
175
fi
172
fi
176
 
173
 
177
if [ -d /tmp/doc/livecd ]; then
174
if [ -d /tmp/doc/livecd ]; then
178
    echo
175
    echo
179
    echo "--------------------------------------------"
176
    echo "--------------------------------------------"
180
    echo "Create /usr/share/doc/livecd"
177
    echo "Create /usr/share/doc/livecd"
181
    echo "--------------------------------------------"
178
    echo "--------------------------------------------"
182
    mkdir -p /usr/share/doc/HTML
179
    mkdir -p /usr/share/doc/HTML
183
    cp -a customize/HTML/index.html /usr/share/doc/HTML/index.html    
180
    cp -a customize/HTML/index.html /usr/share/doc/HTML/index.html    
184
    rm -rf /usr/share/doc/livecd
181
    rm -rf /usr/share/doc/livecd
185
    cp -a /tmp/doc/livecd /usr/share/doc/
182
    cp -a /tmp/doc/livecd /usr/share/doc/
186
    echo "done."
183
    echo "done."
187
    echo
184
    echo
188
fi
185
fi
189
 
186
 
190
echo
187
echo
191
echo "--------------------------------------------"
188
echo "--------------------------------------------"
192
echo "cd linux-live.sl"
189
echo "cd linux-live.sl4"
193
echo "--------------------------------------------"
190
echo "--------------------------------------------"
194
 
191
 
195
cd linux-live.sl
192
cd linux-live.sl4
196
 
193
 
197
echo "Set kernel boot options in cd-root/isolinux.cfg"
194
echo "Set kernel boot options in cd-root/isolinux.cfg"
198
# for lable linux
195
# for lable linux
199
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
196
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
200
# for lable linuxsmp
197
# for lable linuxsmp
201
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
198
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
202
# for lable failsafe
199
# for lable failsafe
203
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
200
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
204
 
201
 
205
echo "Set 'Welcome ... to' in splash.cfg"
202
echo "Set 'Welcome ... to' in splash.cfg"
206
sed -i "s|DVD|CD|" cd-root/boot/splash.cfg
203
sed -i "s|DVD|CD|" cd-root/boot/splash.cfg
207
 
204
 
208
if [ $PSI ]; then
205
if [ $PSI ]; then
209
    sed -i "s|Welcome to.* LiveCD.*|Welcome to PSI $LIVECD_OS LiveCD|" cd-root/boot/splash.cfg
206
    sed -i "s|Welcome to.* LiveCD.*|Welcome to PSI SL4 LiveCD|" cd-root/boot/splash.cfg
210
else
207
else
211
    sed -i "s|Welcome to.* LiveCD.*|Welcome to $RELEASE|" cd-root/boot/splash.cfg
208
    sed -i "s|Welcome to.* LiveCD.*|Welcome to $RELEASE|" cd-root/boot/splash.cfg
212
fi
209
fi
213
 
210
 
214
sed -i "s|LiveCD 64bit|LiveCD|" cd-root/boot/splash.cfg
211
sed -i "s|LiveCD 64bit|LiveCD|" cd-root/boot/splash.cfg
215
if [ "$ARCH" = "x86_64" ]; then
212
if [ "$ARCH" = "x86_64" ]; then
216
    sed -i "s|LiveCD|LiveCD 64bit|" cd-root/boot/splash.cfg
213
    sed -i "s|LiveCD|LiveCD 64bit|" cd-root/boot/splash.cfg
217
fi
214
fi
218
 
215
 
219
if [ $DVD ]; then
216
if [ $DVD ]; then
220
    sed -i "s|CD|DVD|" cd-root/boot/splash.cfg
217
    sed -i "s|CD|DVD|" cd-root/boot/splash.cfg
221
fi
218
fi
222
 
219
 
223
echo "Set KERNEL=$KERNEL in config"
220
echo "Set KERNEL=$KERNEL in config"
224
sed -i "s|^KERNEL=.*|KERNEL=$KERNEL|" config
221
sed -i "s|^KERNEL=.*|KERNEL=$KERNEL|" config
225
 
222
 
226
echo "Set RAM0SIZE=$RAM0SIZE in config"
223
echo "Set RAM0SIZE=$RAM0SIZE in config"
227
sed -i "s|^RAM0SIZE=.*|RAM0SIZE=$RAM0SIZE|" config
224
sed -i "s|^RAM0SIZE=.*|RAM0SIZE=$RAM0SIZE|" config
228
 
225
 
229
echo "Set ramdisk_size=$RAMDISK_SIZE in cd-root/boot/DOS/config"
226
echo "Set ramdisk_size=$RAMDISK_SIZE in cd-root/boot/DOS/config"
230
sed -i "s|^ramdisk_size=.*|ramdisk_size=$RAMDISK_SIZE|" cd-root/boot/DOS/config
227
sed -i "s|^ramdisk_size=.*|ramdisk_size=$RAMDISK_SIZE|" cd-root/boot/DOS/config
231
 
228
 
232
echo
229
echo
233
echo "--------------------------------------------"
230
echo "--------------------------------------------"
234
echo "Run ./runme.sh"
231
echo "Run ./runme.sh"
235
echo "--------------------------------------------"
232
echo "--------------------------------------------"
236
./runme.sh
233
./runme.sh
237
 
234
 
238
echo
235
echo
239
echo "--------------------------------------------"
236
echo "--------------------------------------------"
240
echo "Now fix things to make this system bootable"
237
echo "Now fix things to make this system bootable"
241
echo "--------------------------------------------"
238
echo "--------------------------------------------"
242
cd ..
239
cd ..
243
./restore-system.sh $PSI
240
./restore-system.sh $PSI
244
 
241
 
245
 
242
 
246
echo "--------------------------------------------"
243
echo "--------------------------------------------"
247
echo "End of Build LiveCD" 
244
echo "End of Build LiveCD" 
248
echo "See /tmp for the ISO image"
245
echo "See /tmp for the ISO image"
249
echo "--------------------------------------------"
246
echo "--------------------------------------------"