Contents of /trunk/bootstrap/scripts/bootstrap-magellan.sh
Parent Directory | Revision Log
Revision 161 -
(show annotations)
(download)
(as text)
Fri Jul 29 14:10:30 2005 UTC (19 years, 2 months ago) by niro
File MIME type: application/x-sh
File size: 8146 byte(s)
Fri Jul 29 14:10:30 2005 UTC (19 years, 2 months ago) by niro
File MIME type: application/x-sh
File size: 8146 byte(s)
typo
1 | #!/bin/sh |
2 | # $Header: /home/cvsd/magellan-cvs/magellan-src/bootstrap/scripts/bootstrap-magellan.sh,v 1.2 2005-07-29 14:10:30 niro Exp $ |
3 | # |
4 | # bootstrap-magellan-chrooted-livecd.sh |
5 | # v0.3.6-r7 (21.10.2004) |
6 | # Niels Rogalla (niro@magellan-linux.de) |
7 | # |
8 | # creates a FHS compilant directory hirachy with devfs support |
9 | # then the magellan-baselayout will be installed |
10 | # All this will be handled from the host system via chroot |
11 | |
12 | source /etc/sysconfig/rc |
13 | source $rc_functions |
14 | |
15 | |
16 | ### setup ### |
17 | CDPATH=/mnt/cdrom |
18 | DEST=/mnt/magellan |
19 | TOOLCHAIN=${CDPATH}/bootstrap/tools/magellan-toolchain-0.3-i486.tar.bz2 |
20 | CDMAGEDIR=${CDPATH}/bootstrap/mage-src |
21 | CDMAGETREE=${CDPATH}/mage-tree |
22 | CDPKGDIR=${CDPATH}/packages |
23 | CDMAGERC=/etc/mage.rc |
24 | VERSION=0.3.6-r7 |
25 | METHOD=NET |
26 | |
27 | # which profile ? |
28 | if [ -z "${1}" ] |
29 | then |
30 | CDMAGEPROFILE=kernel24 |
31 | else |
32 | CDMAGEPROFILE="${1}" |
33 | fi |
34 | |
35 | # which layout ? |
36 | if [ -z "${2}" ] |
37 | then |
38 | LAYOUT=basesystem.defaults |
39 | else |
40 | LAYOUT="${2}" |
41 | fi |
42 | |
43 | |
44 | ### functions ### |
45 | die() { |
46 | echo "Error: $@" |
47 | return 1 |
48 | } |
49 | |
50 | secho() { |
51 | local i |
52 | i="$@" |
53 | echo -e "\n${COLOREDSTAR}${i}" |
54 | } |
55 | |
56 | mecho() { |
57 | local i |
58 | i="$@" |
59 | echo -e "${COLMAGENTA}\t${i}${COLDEFAULT}" |
60 | } |
61 | |
62 | necho() { |
63 | local i |
64 | i="$@" |
65 | echo -e "${COLGREEN}${i}${COLDEFAULT}" |
66 | } |
67 | |
68 | showversion() { |
69 | echo -en "Magellan Bootstrap v${VERSION} " |
70 | echo -e "-- Niels Rogalla (niro@magellan-linux.de)" |
71 | } |
72 | |
73 | |
74 | |
75 | if [ -z "${DEST}" ] |
76 | then |
77 | echo -e "\n\$DEST not found. Your Magellan Chroot Variable must be declared." |
78 | echo -e "example: export DEST=/mnt/magellan\n" |
79 | exit 1 |
80 | fi |
81 | |
82 | |
83 | enter_chroot() { |
84 | secho Entering Chroot ... |
85 | mount -t proc proc ${DEST}/proc |
86 | mount -o bind /dev ${DEST}/dev |
87 | |
88 | chroot ${DEST} /tools/bin/env -i \ |
89 | HOME=/root TERM=$TERM PS1='\u:\w\$ ' \ |
90 | PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \ |
91 | /tools/bin/bash -i |
92 | |
93 | secho Cleanup Chroot ... |
94 | mecho Unmounting Chroot filesystems ... |
95 | ( |
96 | umount ${DEST}/proc |
97 | umount ${DEST}/dev |
98 | ) |
99 | evaluate_retval |
100 | |
101 | if [[ ${METHOD} = CDROM ]] |
102 | then |
103 | mecho Unmounting Mage directories ... |
104 | ( |
105 | umount ${DEST}/usr/packages |
106 | umount ${DEST}/usr/mage |
107 | ) |
108 | evaluate_retval |
109 | fi |
110 | |
111 | if [ -e ${DEST}/root/.bashrc ] |
112 | then |
113 | mecho Deleting instruction file ... |
114 | rm ${DEST}/root/.bashrc |
115 | evaluate_retval |
116 | fi |
117 | } |
118 | |
119 | create_chrootdirs() { |
120 | local i |
121 | |
122 | # creating directories |
123 | install -d ${DEST}/{bin,boot,dev/shm,etc,home,lib/dev-state,mnt,proc} || die |
124 | install -d ${DEST}/etc/{opt,env.d} || die |
125 | install -d ${DEST}/mnt/{floppy,cdrom} || die |
126 | install -d ${DEST}/{root,sbin,tmp,usr/local,var,opt} || die |
127 | for i in ${DEST}/usr ${DEST}/usr/local |
128 | do |
129 | install -d ${i}/{bin,etc,include,lib,sbin,share,src} || die |
130 | ln -snf share/{man,doc,info} ${i} || die |
131 | install -d ${i}/share/{dict,doc,info,locale,man} || die |
132 | install -d ${i}/share/{nls,misc,terminfo,zoneinfo} || die |
133 | install -d ${i}/share/man/man{1,2,3,4,5,6,7,8} || die |
134 | done |
135 | install -d ${DEST}/var/{lock,log,mail,run,spool} || die |
136 | install -d ${DEST}/var/{tmp,opt,cache,lib/misc,local} || die |
137 | install -d ${DEST}/opt/{bin,doc,include,info} || die |
138 | install -d ${DEST}/opt/{lib,man/man{1,2,3,4,5,6,7,8}} || die |
139 | |
140 | ## correcting some rights |
141 | chmod 0750 ${DEST}/root || die |
142 | chmod 1777 ${DEST}/tmp || die |
143 | chmod 1777 ${DEST}/var/tmp || die |
144 | |
145 | ## creating .keep files |
146 | touch ${DEST}/{bin,boot,dev/shm,etc,home,lib/dev-state,mnt,proc}/.keep || die |
147 | touch ${DEST}/etc/{opt,env.d}/.keep || die |
148 | touch ${DEST}/mnt/{floppy,cdrom}/.keep || die |
149 | touch ${DEST}/dev/.keep || die |
150 | touch ${DEST}/etc/.keep || die |
151 | touch ${DEST}/{root,sbin,tmp,usr/local,var,opt}/.keep || die |
152 | touch ${DEST}/usr/.keep || die |
153 | for i in ${DEST}/usr ${DEST}/usr/local |
154 | do |
155 | touch ${i}/{bin,etc,include,lib,sbin,share,src}/.keep || die |
156 | touch ${i}/share/{dict,doc,info,locale,man}/.keep || die |
157 | touch ${i}/share/{nls,misc,terminfo,zoneinfo}/.keep || die |
158 | touch ${i}/share/man/man{1,2,3,4,5,6,7,8}/.keep || die |
159 | done |
160 | touch ${DEST}/var/.keep || die |
161 | touch ${DEST}/var/{lock,log,mail,run,spool}/.keep || die |
162 | touch ${DEST}/var/{tmp,opt,cache,lib/misc,local}/.keep || die |
163 | touch ${DEST}/opt/.keep || die |
164 | touch ${DEST}/opt/{bin,doc,include,info}/.keep || die |
165 | touch ${DEST}/opt/{lib,man/man{1,2,3,4,5,6,7,8}}/.keep || die |
166 | touch ${DEST}/opt/man/.keep || die |
167 | } |
168 | |
169 | |
170 | create_symlinks(){ |
171 | mecho Creating symlinks ... |
172 | ## Creating some essential symlinks for bootstrap |
173 | ( |
174 | ## Creating the bash and sh symlinks |
175 | ln -snf /tools/bin/{basename,bash,cat,cut,date} ${DEST}/bin || die |
176 | ln -snf /tools/bin/{dirname,egrep,fgrep,grep} ${DEST}/bin || die |
177 | ln -snf /tools/bin/{ls,pwd,sed,stty,wc,whoami} ${DEST}/bin || die |
178 | ln -snf /tools/lib/libgcc_s.so.1 ${DEST}/usr/lib || die |
179 | ln -snf /tools/sbin/ldconfig ${DEST}/sbin/ldconfig || die |
180 | ln -snf bash ${DEST}/bin/sh || die |
181 | |
182 | ## needed empty files (to prevent warnings only) |
183 | touch ${DEST}/etc/env.d/dummy || die |
184 | touch ${DEST}/etc/profile || die |
185 | install -d ${DEST}/etc/rc.d/init.d || die |
186 | touch ${DEST}/etc/rc.d/init.d/functions || die |
187 | ln -snf /etc/rc.d/init.d ${DEST}/etc/init.d || die |
188 | ) |
189 | |
190 | evaluate_retval |
191 | } |
192 | |
193 | create_devices(){ |
194 | mecho Creating needed devices for devfs/udev |
195 | ( |
196 | mknod -m 611 ${DEST}/dev/console c 5 1 |
197 | chgrp 4 ${DEST}/dev/console |
198 | mknod -m 666 ${DEST}/dev/null c 1 3 |
199 | ) |
200 | evaluate_retval |
201 | } |
202 | |
203 | unpack_toolchain(){ |
204 | mecho Unpacking toolchain ... |
205 | tar --no-same-owner -xvjf ${TOOLCHAIN} -C ${DEST} |
206 | evaluate_retval |
207 | } |
208 | |
209 | install_mage(){ |
210 | if [[ ${METHOD} = CDROM ]] |
211 | then |
212 | mecho Installing Mage ... |
213 | ( |
214 | install -d ${DEST}/usr/lib/mage |
215 | install -d ${DEST}/etc/rc.d/init.d |
216 | ${CDMAGEDIR}/setup_mage.sh \ |
217 | ${DEST} ${CDMAGEDIR} ${CDMAGERC} ${CDMAGEPROFILE} |
218 | mount -o bind ${CDMAGETREE} ${DEST}/usr/mage |
219 | mount -o bind ${CDPKGDIR} ${DEST}/usr/packages |
220 | ) |
221 | evaluate_retval |
222 | fi |
223 | |
224 | if [[ ${METHOD} = NET ]] |
225 | then |
226 | mecho Installing Mage ... |
227 | ( |
228 | install -d ${DEST}/usr/lib/mage |
229 | install -d ${DEST}/etc/rc.d/init.d |
230 | ${CDMAGEDIR}/setup_mage.sh \ |
231 | ${DEST} ${CDMAGEDIR} ${CDMAGERC} ${CDMAGEPROFILE} |
232 | ) |
233 | evaluate_retval |
234 | fi |
235 | } |
236 | |
237 | create_users() { |
238 | mecho Creating basic passwd file ... |
239 | echo 'root:x:0:0:root:/root:/bin/bash' > ${DEST}/etc/passwd |
240 | evaluate_retval |
241 | |
242 | mecho Creating basic groups file ... |
243 | cat > ${DEST}/etc/group << "EOF" |
244 | root:x:0: |
245 | bin:x:1: |
246 | sys:x:2: |
247 | kmem:x:3: |
248 | tty:x:4: |
249 | tape:x:5: |
250 | daemon:x:6: |
251 | floppy:x:7: |
252 | disk:x:8: |
253 | lp:x:9: |
254 | dialout:x:10: |
255 | audio:x:11: |
256 | EOF |
257 | evaluate_retval |
258 | |
259 | } |
260 | |
261 | |
262 | create_bashrc() { |
263 | cat ${rc_functions} > ${DEST}/root/.bashrc |
264 | cat >> ${DEST}/root/.bashrc << "EOF" |
265 | die() { |
266 | DIE="yes" |
267 | } |
268 | secho() { |
269 | local i |
270 | i="$@" |
271 | echo -e "\n${COLOREDSTAR}${i}" |
272 | } |
273 | mecho() { |
274 | local i |
275 | i="$@" |
276 | echo -e "${COLMAGENTA}\t${i}${COLDEFAULT}" |
277 | } |
278 | EOF |
279 | echo "export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin" >> ${DEST}/root/.bashrc |
280 | echo "export METHOD=${METHOD}" >> ${DEST}/root/.bashrc |
281 | echo "export LAYOUT=${LAYOUT}" >> ${DEST}/root/.bashrc |
282 | echo "export CDMAGEPROFILE=${CDMAGEPROFILE}" >> ${DEST}/root/.bashrc |
283 | |
284 | ( source ${CDMAGERC}; echo "export MY_MAGEDIR=${MAGEDIR}" >> ${DEST}/root/.bashrc ) |
285 | |
286 | cat >> ${DEST}/root/.bashrc << "EOF" |
287 | if [[ ${METHOD} = NET ]] |
288 | then |
289 | mecho Updating Mage ... |
290 | mage update |
291 | fi |
292 | |
293 | # using default profile (if nothing given == kernel24) |
294 | mecho Using ${MY_MAGEDIR}/profiles/${CDMAGEPROFILE}/${LAYOUT} |
295 | source /etc/mage.rc |
296 | ln -snf ${MY_MAGEDIR}/profiles/${CDMAGEPROFILE} /etc/mage-profile |
297 | |
298 | MY_LAYOUT=$(< /etc/mage-profile/${LAYOUT}) |
299 | |
300 | mecho Installing Baselayout ... |
301 | CONFIG_PROTECT="-*" mage install ${MY_LAYOUT} |
302 | #evaluate_retval |
303 | |
304 | mecho Please enter a root password |
305 | passwd root |
306 | exit |
307 | EOF |
308 | } |
309 | |
310 | |
311 | |
312 | # bootstrap process starts here |
313 | showversion |
314 | secho Starting bootstrap... |
315 | |
316 | unpack_toolchain |
317 | |
318 | mecho Creating directories ... |
319 | create_chrootdirs |
320 | evaluate_retval |
321 | |
322 | create_symlinks |
323 | create_devices |
324 | install_mage |
325 | create_users |
326 | |
327 | create_bashrc |
328 | enter_chroot |
329 | |
330 | secho Bootstraping finished... |
331 | echo |
332 | necho "Your System isn't configured yet ..." |
333 | necho "Please edit /etc/fstab," |
334 | necho " /etc/hostname," |
335 | necho " /etc/hosts," |
336 | necho " /etc/resolv.conf," |
337 | necho " /etc/modules.autoload/kernel-VERSION," |
338 | necho " /boot/grub/grub.conf" |
339 | necho "that they fit to your needs ..." |
340 | necho "Don't forget to write your bootsector ..." |
341 | necho "After that you can delete ${DEST}/tools and reboot your system ..." |
342 | echo |
Properties
Name | Value |
---|---|
svn:executable | * |