Subversion Repositories livecd

Rev

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

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