Annotation of elwix/build_fs.sh, revision 1.3.2.10
1.2 misho 1: #!/bin/sh
2: #
3: # ELWIX Build script for ELWIX CompactFlash image
4: #
5: # (C) AITNET ltd - Sofia/Bulgaria <office@aitnet.org>
6: # by Michael Pounov <misho@elwix.org>
7: #
1.3.2.10! misho 8: # $Id: build_fs.sh,v 1.3.2.9 2012/10/10 09:22:08 misho Exp $
1.2 misho 9: #
10:
11: [ -r ./config/rc.elwix ] && . ./config/rc.elwix
12: if [ X"${ELWIX_IS_CONFIGURED}" != X"YES" ]; then
13: echo
14: echo "ELWIX project is not configured !?!"
15: echo
16: exit 1
17: fi
18:
19: if [ ! -d ${BSDSRC} ]; then
20: echo
21: echo "ELWIX project is not configured - missing BSD sources !?!"
22: echo
23: exit 1
24: fi
25:
26: if [ "${USER}" != "root" ]; then
27: echo
28: echo "ELWIX project is not configured - FS must build under root !?!"
29: echo
30: exit 1
31: fi
32:
33: clean_fsdir()
34: {
35: echo "+++ Clean ELWIX FS ..."
36: rm -rf ${FS}
37:
38: echo "+++ Clean ELWIX FS release ..."
39: rm -rf ${REL}/${OS}
40: }
41:
42: build_fsdir()
43: {
44: echo "+++ Build ELWIX FS directory ..."
45: mkdir -p ${FS}
46:
47: cd ${FS}
48:
49: # altroot
50: install -d altroot;
51: # altroot/var
52: install -d altroot/var;
53: install -d altroot/var/account;
54: install -d altroot/var/at;
55: install -d altroot/var/at/jobs;
56: install -d altroot/var/at/spool;
1.3.2.7 misho 57: install -d -g 63 -m 0770 altroot/var/authpf;
1.2 misho 58: install -d -m 0750 altroot/var/cron;
59: install -d -m 0700 altroot/var/cron/tabs;
60: install -d altroot/var/db;
61: install -d -m 0555 altroot/var/empty;
62: install -d altroot/var/log;
1.3.2.8 misho 63: # install -d -o 80 -g 80 altroot/var/log/lighttpd;
1.3.2.7 misho 64: install -d -o 101 -g 101 altroot/var/log/quagga;
1.2 misho 65: install -d altroot/var/named;
66: install -d altroot/var/run;
1.3.2.8 misho 67: # install -d -o 80 -g 80 altroot/var/run/lighttpd;
1.3.2.7 misho 68: install -d -o 53 -g 53 altroot/var/run/named;
69: install -d -o 101 -g 101 altroot/var/run/quagga;
1.2 misho 70: install -d altroot/var/spool;
1.3.2.7 misho 71: install -d -o 66 -g 68 -m 0775 altroot/var/spool/lock;
72: install -d -g 1 altroot/var/spool/lpd;
73: install -d -g 1 altroot/var/spool/output;
74: install -d -g 1 altroot/var/spool/output/lpd;
1.2 misho 75: # boot
76: install -d boot;
77: # cf
78: install -d cf;
79: # etc
80: install -d etc;
81: # exports
82: install -d exports;
83: # home
84: install -d home;
85: # root
86: install -d -m 0700 root;
1.3.2.4 misho 87: # pkg
88: install -d pkg;
89: install -d pkg/db;
1.3.2.6 misho 90: install -d pkg/lib;
1.2 misho 91: # tftpboot
92: install -d tftpboot;
93:
94: chown -hR root:wheel .
95: cd -
96: }
97:
98: mkboot()
99: {
100: echo "+++ Build ELWIX FS boot directory ..."
101: InstallDir ${WORLD}/boot $1/boot
102:
103: install -m 644 ${CFGDIR}/boot/boot.config $1;
1.3 misho 104:
105: install -m 444 ${CFGDIR}/boot/beastie.4th $1/boot;
106: install -m 444 ${CFGDIR}/boot/brand.4th $1/boot;
107: install -m 444 ${CFGDIR}/boot/menu.4th $1/boot;
108:
109: install -m 444 ${KERNDEVHINTS} $1/boot/device.hints;
1.2 misho 110:
111: if [ -r ${CFGDIR}/boot/loader_${TARGET_ARCH}.conf ]; then
112: install -m 644 ${CFGDIR}/boot/loader_${TARGET_ARCH}.conf $1/boot/loader.conf;
113: else
114: echo;
115: echo "Can't find right loader.conf for TARGET_ARCH=${TARGET_ARCH} ... loader.conf not installed!";
116: echo;
117: fi;
118: }
119:
120: mkvar()
121: {
122: echo "+++ Build ELWIX FS var directory ..."
123: ln -s /tmp $1/altroot/var/tmp
124:
125: touch $1/altroot/var/log/elwix
126: touch $1/altroot/var/log/lastlog
127: touch $1/altroot/var/log/wifi.log
128: touch $1/altroot/var/log/wtmp
129: touch $1/altroot/var/run/utmp
130: touch $1/altroot/var/account/acct
131:
132: touch $1/altroot/var/log/auth.log
133: touch $1/altroot/var/log/cron
134: touch $1/altroot/var/log/console.log
135: touch $1/altroot/var/log/debug.log
136: touch $1/altroot/var/log/lpd-errs
137: touch $1/altroot/var/log/maillog
138: touch $1/altroot/var/log/messages
139: touch $1/altroot/var/log/security
140: touch $1/altroot/var/log/xferlog
141: touch $1/altroot/var/log/ppp.log
142: chgrp network $1/altroot/var/log/ppp.log
143:
144: InstallDir ${WORLD}/var/named $1/altroot/var/named
145: InstallList ${ELWIX_BSDSRC} ${BSDSRC} $1/altroot/var/named
146: install -v ${FS_ETC}/resolv.safe $1/altroot/var/run/resolv.conf
147: }
148:
149: create_etc_motd()
150: {
151: ELWIX_VER="ELWIX-${VERSION}_${TARGET_ARCH}";
152: ELWIX_HDR_MOTD="${ELWIX_VER} :: Build date ${BUILD_DATE}";
153:
154: awk -v fo="${1:-motd}" 'BEGIN { print "'"${ELWIX_HDR_MOTD}"'" > fo; } { print $0 >> fo; }' \
155: ${CFGDIR}/elwix_signature.txt;
156: }
157:
158: create_etc_fstab()
159: {
160: cat >$1 <<_EOF
161: # Automatic generated fstab for ELWIX at ${BUILD_DATE}
162: #
163: /dev/ufs/elwix /elwix ufs ro 0 1
164: md3 /tmp mfs rw,-s8m,-oasync,-S 0 0
165: md4 /var mfs rw,-s16m,-S 0 0
166: _EOF
167: }
168:
169: mketc()
170: {
171: echo "+++ Build ELWIX FS etc directory ..."
172: InstallDir ${FS_ETC} $1/etc
173:
174: chown -R root:wheel $1/etc;
175:
176: chmod 0600 $1/etc/opieaccess;
177: chmod 0600 $1/etc/opiekeys;
178:
179: chmod 0600 $1/etc/master.passwd;
180: chmod 0600 $1/etc/spwd.db;
181: chmod 0600 $1/etc/ssh/ssh_host_dsa_key;
182: chmod 0600 $1/etc/ssh/ssh_host_key;
183: chmod 0600 $1/etc/ssh/ssh_host_rsa_key;
1.3 misho 184: chmod 0600 $1/etc/ssh/ssh_host_ecdsa_key;
1.2 misho 185:
186: chmod 0440 $1/etc/sudoers;
187:
1.3.2.7 misho 188: chgrp 80 $1/etc/config.xml;
1.2 misho 189: chmod 0660 $1/etc/config.xml;
190:
191: ln -sf /etc/rc.s $1/etc/rc.S
192:
193: ln -sf /usr/share/zoneinfo/${TIMEZONE} $1/etc/localtime;
194: ln -sf /usr/share/misc/termcap $1/etc/termcap;
195:
196: ln -sf /var/named/etc/namedb $1/etc/namedb;
197: ln -sf /var/run/resolv.conf $1/etc/resolv.conf;
198:
1.3.2.5 misho 199: ln -sf /elwix/pkg/etc/mk.conf $1/etc/mk.conf;
200:
1.2 misho 201: echo ${TARGET_ARCH} >$1/etc/platform;
202:
203: create_etc_motd $1/etc/motd;
204: create_etc_fstab $1/etc/fstab;
1.3.2.3 misho 205:
206: echo "+++ ELWIX clean CVS tags ..."
207: CleanCVS ${FS}
208: CleanCVS ${FS}/etc
1.2 misho 209: }
210:
211: mkbackup()
212: {
213: echo "+++ Build ELWIX FS backup factory default directory ..."
214: mkdir -p $1/altroot/backup
215:
216: cd $1
217: cp -p etc/config.xml altroot/backup
1.3.2.7 misho 218: tar -czf altroot/backup/.etc.tgz etc
219:
1.2 misho 220: cd altroot
221: tar -czf backup/.var.tgz var
222: }
223:
224: mkhome()
225: {
226: echo "+++ Build ELWIX FS root home directory ..."
227: install -d $1/root/.ssh
228: [ -r ${CFGDIR}/root.skel/ssh/authorized_keys2 ] && \
229: install -v ${CFGDIR}/root.skel/ssh/authorized_keys2 $1/root/.ssh;
230:
231: install -v ${CFGDIR}/root.skel/cshrc $1/root/.cshrc;
232: install -v ${CFGDIR}/root.skel/login $1/root/.login;
233: install -v ${CFGDIR}/root.skel/logout $1/root/.logout;
234: install -v ${CFGDIR}/root.skel/profile $1/root/.profile;
235: install -v ${CFGDIR}/root.skel/vimrc $1/root/.vimrc;
236: }
237:
238: install_fsdir()
239: {
240: echo "+++ Install ELWIX FS in bundle OS install file ..."
241:
242: install -v ${REL}/${ROOTFS_KERN} ${FS}/boot/kernel
243:
1.3.2.9 misho 244: if [ "${BUILD_FRMIMG}" = "YES" ]; then
245: install -v ${REL}/${ROMFS_IMG} ${FS}/altroot/elwix-firmware-${VERSION}_${TARGET_ARCH}
246: ln ${FS}/altroot/elwix-firmware-${VERSION}_${TARGET_ARCH} ${FS}/altroot/${ROMFS_IMG}
247: ln -s /elwix/altroot/elwix-firmware-${VERSION}_${TARGET_ARCH} ${FS}/${ROMFS_IMG}
1.3.2.10! misho 248:
! 249: install -v ${REL}/${ROMFS_IMG2} ${FS}/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH}
! 250: ln ${FS}/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH} ${FS}/altroot/${ROMFS_IMG2}
! 251: ln -s /elwix/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH} ${FS}/${ROMFS_IMG2}
1.3.2.9 misho 252: else
253: install -d ${FS}/usr
254: cd ${FS}/usr
255: pax -r -z -pe -f ${REL}/${ROMFS_IMG}
256: cd -
257: fi
1.2 misho 258:
259: cd $FS
260: tar -czvf ${REL}/${OS} .
261: }
262:
263: ### main()
264: if [ ! -r ${REL}/${ROOTFS_KERN} -o ! -r ${REL}/${ROMFS_IMG} ]; then
265: echo
266: echo "Error:: not found kernel or firmware elwix files ..."
267: echo
268: echo " For fix this issue, please re-run build_rootfs.sh or build_romfs.sh"
269: echo
270: exit 1
271: fi
272:
273: clean_fsdir
274: build_fsdir
275:
276: mkboot ${FS}
277: mkhome ${FS}
278: mkvar ${FS}
279: mketc ${FS}
280: mkbackup ${FS}
281:
282: install_fsdir
283:
284: echo "+++ Complete build ELWIX FS"
285: echo "ELWIX finish version ${VERSION}, Good luck!"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>