Subversion Repositories livecd

Rev

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

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