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