Annotation of elwix/build_fs.sh, revision 1.7.2.7
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.7.2.7 ! misho 8: # $Id: build_fs.sh,v 1.7.2.6 2013/07/31 13:56:23 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:
1.7.2.1 misho 33: clean_rel()
1.2 misho 34: {
1.7.2.1 misho 35: echo "+++ Clean ELWIX OS release ..."
1.7.2.2 misho 36: rm -rf $1 $2
37:
38: mkdir -p $1
39:
1.7.2.7 ! misho 40: if [ -d ${BASEFS} ]; then
! 41: cd ${BASEFS}
! 42: pax -rw -pe -X . $1
! 43: cd -
! 44: fi
1.2 misho 45: }
46:
1.7.2.1 misho 47: build_vardir()
1.2 misho 48: {
1.7.2.1 misho 49: echo "+++ Build ELWIX altroot directory ..."
1.2 misho 50:
1.4 misho 51: cd $1
1.2 misho 52: # altroot
53: install -d altroot;
54: # altroot/var
55: install -d altroot/var;
56: install -d altroot/var/account;
57: install -d altroot/var/at;
58: install -d altroot/var/at/jobs;
59: install -d altroot/var/at/spool;
1.4 misho 60: install -d -g 63 -m 0770 altroot/var/authpf;
1.2 misho 61: install -d -m 0750 altroot/var/cron;
62: install -d -m 0700 altroot/var/cron/tabs;
63: install -d altroot/var/db;
64: install -d -m 0555 altroot/var/empty;
65: install -d altroot/var/log;
1.4 misho 66: install -d -o 101 -g 101 altroot/var/log/quagga;
67: install -d -o 883 -g 883 altroot/var/mqtt;
1.2 misho 68: install -d altroot/var/named;
69: install -d altroot/var/run;
1.4 misho 70: install -d altroot/var/sys;
71: install -d -o 53 -g 53 altroot/var/run/named;
72: install -d -o 101 -g 101 altroot/var/run/quagga;
1.2 misho 73: install -d altroot/var/spool;
1.4 misho 74: install -d -o 66 -g 68 -m 0775 altroot/var/spool/lock;
75: install -d -g 1 altroot/var/spool/lpd;
76: install -d -g 1 altroot/var/spool/output;
77: install -d -g 1 altroot/var/spool/output/lpd;
1.2 misho 78:
1.7.2.4 misho 79: ln -fs /tmp altroot/var/tmp;
80:
1.2 misho 81: chown -hR root:wheel .
82: cd -
83: }
84:
85: mkboot()
86: {
1.7.2.2 misho 87: echo "+++ Build ELWIX OS boot directory ..."
1.2 misho 88: InstallDir ${WORLD}/boot $1/boot
89:
90: install -m 644 ${CFGDIR}/boot/boot.config $1;
1.3 misho 91:
92: install -m 444 ${CFGDIR}/boot/beastie.4th $1/boot;
93: install -m 444 ${CFGDIR}/boot/brand.4th $1/boot;
94: install -m 444 ${CFGDIR}/boot/menu.4th $1/boot;
95:
96: install -m 444 ${KERNDEVHINTS} $1/boot/device.hints;
1.2 misho 97:
98: if [ -r ${CFGDIR}/boot/loader_${TARGET_ARCH}.conf ]; then
99: install -m 644 ${CFGDIR}/boot/loader_${TARGET_ARCH}.conf $1/boot/loader.conf;
100: else
101: echo;
102: echo "Can't find right loader.conf for TARGET_ARCH=${TARGET_ARCH} ... loader.conf not installed!";
103: echo;
104: fi;
105: }
106:
107: mkvar()
108: {
1.7.2.2 misho 109: echo "+++ Build ELWIX OS var directory ..."
1.5 misho 110: touch $1/altroot/var/run/utmp
111:
112: touch $1/altroot/var/account/acct
113:
1.2 misho 114: touch $1/altroot/var/log/elwix
115: touch $1/altroot/var/log/lastlog
116: touch $1/altroot/var/log/wifi.log
1.5 misho 117: touch $1/altroot/var/log/utx.log
1.2 misho 118:
119: touch $1/altroot/var/log/auth.log
120: touch $1/altroot/var/log/cron
121: touch $1/altroot/var/log/console.log
122: touch $1/altroot/var/log/debug.log
1.5 misho 123: touch $1/altroot/var/log/init.log
1.2 misho 124: touch $1/altroot/var/log/lpd-errs
125: touch $1/altroot/var/log/maillog
126: touch $1/altroot/var/log/messages
127: touch $1/altroot/var/log/security
128: touch $1/altroot/var/log/xferlog
129: touch $1/altroot/var/log/ppp.log
130: chgrp network $1/altroot/var/log/ppp.log
131:
132: InstallDir ${WORLD}/var/named $1/altroot/var/named
133: InstallList ${ELWIX_BSDSRC} ${BSDSRC} $1/altroot/var/named
134: install -v ${FS_ETC}/resolv.safe $1/altroot/var/run/resolv.conf
135: }
136:
137: create_etc_motd()
138: {
1.4 misho 139: ELWIX_VER="ELWIX$2-${VERSION}_${TARGET_ARCH}";
1.2 misho 140: ELWIX_HDR_MOTD="${ELWIX_VER} :: Build date ${BUILD_DATE}";
141:
142: awk -v fo="${1:-motd}" 'BEGIN { print "'"${ELWIX_HDR_MOTD}"'" > fo; } { print $0 >> fo; }' \
143: ${CFGDIR}/elwix_signature.txt;
144: }
145:
146: create_etc_fstab()
147: {
148: cat >$1 <<_EOF
1.4 misho 149: # Automatic generated fstab for ELWIX$2 at ${BUILD_DATE}
1.2 misho 150: #
1.7.2.1 misho 151: /dev/ufs/elwix / ufs ro 0 1
1.7.2.4 misho 152: md2 /tmp mfs rw,-s8m,-oasync,-S 0 0
153: md3 /var mfs rw,-s16m,-S 0 0
1.2 misho 154: _EOF
155: }
156:
157: mketc()
158: {
1.7.2.1 misho 159: echo "+++ Build ELWIX OS etc directory ..."
1.2 misho 160: InstallDir ${FS_ETC} $1/etc
161:
162: chown -R root:wheel $1/etc;
163:
164: chmod 0600 $1/etc/opieaccess;
165: chmod 0600 $1/etc/opiekeys;
166:
167: chmod 0600 $1/etc/master.passwd;
168: chmod 0600 $1/etc/spwd.db;
169: chmod 0600 $1/etc/ssh/ssh_host_dsa_key;
170: chmod 0600 $1/etc/ssh/ssh_host_key;
171: chmod 0600 $1/etc/ssh/ssh_host_rsa_key;
1.3 misho 172: chmod 0600 $1/etc/ssh/ssh_host_ecdsa_key;
1.2 misho 173:
174: chmod 0440 $1/etc/sudoers;
175:
1.4 misho 176: chgrp 80 $1/etc/config.xml;
1.2 misho 177: chmod 0660 $1/etc/config.xml;
178:
1.7.2.2 misho 179: mkdir -p $1/etc/mqtt;
1.4 misho 180: chgrp -R 883 $1/etc/mqtt;
181: chown -R 883 $1/etc/mqtt;
182:
1.2 misho 183: ln -sf /etc/rc.s $1/etc/rc.S
184:
185: ln -sf /usr/share/zoneinfo/${TIMEZONE} $1/etc/localtime;
186: ln -sf /usr/share/misc/termcap $1/etc/termcap;
187:
188: ln -sf /var/named/etc/namedb $1/etc/namedb;
189: ln -sf /var/run/resolv.conf $1/etc/resolv.conf;
190:
1.4 misho 191: ln -sf /elwix/pkg/etc/mk.conf $1/etc/mk.conf;
192:
1.2 misho 193: echo ${TARGET_ARCH} >$1/etc/platform;
194:
1.4 misho 195: create_etc_motd $1/etc/motd $2;
196: create_etc_fstab $1/etc/fstab $2;
197:
198: echo "+++ ELWIX clean CVS tags ..."
199: CleanCVS $1
200: CleanCVS $1/etc
1.2 misho 201: }
202:
203: mkbackup()
204: {
1.7.2.1 misho 205: echo "+++ Build ELWIX OS backup factory default directory ..."
1.2 misho 206: mkdir -p $1/altroot/backup
207:
208: cd $1
1.4 misho 209: cp -p etc/config.xml altroot/backup
1.7.2.6 misho 210: tar -czf altroot/backup/.etc.tgz etc
1.4 misho 211:
1.7.2.6 misho 212: cd altroot
213: tar -czf backup/.var.tgz var
1.2 misho 214: }
215:
216: mkhome()
217: {
1.7.2.1 misho 218: echo "+++ Build ELWIX OS root home directory ..."
1.2 misho 219: install -d $1/root/.ssh
220: [ -r ${CFGDIR}/root.skel/ssh/authorized_keys2 ] && \
221: install -v ${CFGDIR}/root.skel/ssh/authorized_keys2 $1/root/.ssh;
222:
223: install -v ${CFGDIR}/root.skel/cshrc $1/root/.cshrc;
224: install -v ${CFGDIR}/root.skel/login $1/root/.login;
225: install -v ${CFGDIR}/root.skel/logout $1/root/.logout;
226: install -v ${CFGDIR}/root.skel/profile $1/root/.profile;
227: install -v ${CFGDIR}/root.skel/vimrc $1/root/.vimrc;
228: }
229:
1.7.2.1 misho 230: install_rel()
1.2 misho 231: {
1.7.2.1 misho 232: echo "+++ Install ELWIX OS $1 in bundle OS install file ..."
1.4 misho 233: OSZ=""
234:
1.7.2.1 misho 235: install -v ${KERNEL} $1/boot/kernel;
236: cd $1/boot/kernel;
237: gzip -9 kernel;
238: cd -;
1.2 misho 239:
1.5 misho 240: case "$2" in
241: *)
242: OSZ=${REL}/${OS}
243: ;;
244: esac
1.2 misho 245:
1.4 misho 246: cd $1
247: tar -czvf $OSZ .
1.2 misho 248: }
249:
250: ### main()
1.7.2.2 misho 251: clean_rel ${FS} ${REL}/${OS}
252: build_vardir ${FS}/elwix
253: mkhome ${FS}/elwix
254: mkvar ${FS}/elwix
255: mketc ${FS}/elwix
256: mkbackup ${FS}/elwix
257: mkboot ${FS}
258: install_rel ${FS}
1.2 misho 259:
1.7.2.1 misho 260: echo "+++ Complete build ELWIX OS"
1.2 misho 261: echo "ELWIX finish version ${VERSION}, Good luck!"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>