--- elwix/build_fs.sh 2011/07/25 13:03:51 1.1.2.5 +++ elwix/build_fs.sh 2017/10/08 00:05:36 1.11.2.8 @@ -5,7 +5,7 @@ # (C) AITNET ltd - Sofia/Bulgaria # by Michael Pounov # -# $Id: build_fs.sh,v 1.1.2.5 2011/07/25 13:03:51 misho Exp $ +# $Id: build_fs.sh,v 1.11.2.8 2017/10/08 00:05:36 misho Exp $ # [ -r ./config/rc.elwix ] && . ./config/rc.elwix @@ -32,46 +32,20 @@ fi clean_fsdir() { - echo "+++ Clean ELWIX FS ..." - rm -rf ${FS} - - echo "+++ Clean ELWIX FS release ..." - rm -rf ${REL}/${OS} + echo "+++ Clean ELWIX FS ... $1" + chflags -Rf nosunlink $1 + rm -rf $1 $2 } build_fsdir() { - echo "+++ Build ELWIX FS directory ..." - mkdir -p ${FS} + # + # Structure of ELWIX CF Drive mount on /elwix + # + echo "+++ Build ELWIX FS directory ... $1" + mkdir -p $1 - cd ${FS} - -# altroot - install -d altroot; - # altroot/var - install -d altroot/var; - install -d altroot/var/account; - install -d altroot/var/at; - install -d altroot/var/at/jobs; - install -d altroot/var/at/spool; - install -d -g authpf -m 0770 altroot/var/authpf; - install -d -m 0750 altroot/var/cron; - install -d -m 0700 altroot/var/cron/tabs; - install -d altroot/var/db; - install -d -m 0555 altroot/var/empty; - install -d altroot/var/log; - install -d -o www -g www altroot/var/log/lighttpd; - install -d -o quagga -g quagga altroot/var/log/quagga; - install -d altroot/var/named; - install -d altroot/var/run; - install -d -o www -g www altroot/var/run/lighttpd; - install -d -o bind -g bind altroot/var/run/named; - install -d -o quagga -g quagga altroot/var/run/quagga; - install -d altroot/var/spool; - install -d -o uucp -g dialer -m 0775 altroot/var/spool/lock; - install -d -g daemon altroot/var/spool/lpd; - install -d -g daemon altroot/var/spool/output; - install -d -g daemon altroot/var/spool/output/lpd; + cd $1 # boot install -d boot; # cf @@ -82,10 +56,12 @@ build_fsdir() install -d exports; # home install -d home; -# root - install -d -m 0700 root; # local install -d local; +# root + install -d -m 0750 root; +# pkg + install -d pkg; # tftpboot install -d tftpboot; @@ -93,152 +69,63 @@ build_fsdir() cd - } -mkboot() -{ - echo "+++ Build ELWIX FS boot directory ..." - InstallDir ${WORLD}/boot $1/boot - - install -m 644 ${CFGDIR}/boot/boot.config $1; - install -m 644 ${CFGDIR}/boot/beastie.4th $1/boot; - install -m 644 ${CFGDIR}/boot/brand.4th $1/boot; - - if [ -r ${CFGDIR}/boot/loader_${TARGET_ARCH}.conf ]; then - install -m 644 ${CFGDIR}/boot/loader_${TARGET_ARCH}.conf $1/boot/loader.conf; - else - echo; - echo "Can't find right loader.conf for TARGET_ARCH=${TARGET_ARCH} ... loader.conf not installed!"; - echo; - fi; -} - -mkvar() -{ - echo "+++ Build ELWIX FS var directory ..." - ln -s /tmp $1/altroot/var/tmp - - touch $1/altroot/var/log/elwix - touch $1/altroot/var/log/lastlog - touch $1/altroot/var/log/wifi.log - touch $1/altroot/var/log/wtmp - touch $1/altroot/var/run/utmp - touch $1/altroot/var/account/acct - - touch $1/altroot/var/log/auth.log - touch $1/altroot/var/log/cron - touch $1/altroot/var/log/console.log - touch $1/altroot/var/log/debug.log - touch $1/altroot/var/log/lpd-errs - touch $1/altroot/var/log/maillog - touch $1/altroot/var/log/messages - touch $1/altroot/var/log/security - touch $1/altroot/var/log/xferlog - touch $1/altroot/var/log/ppp.log - chgrp network $1/altroot/var/log/ppp.log - - InstallDir ${WORLD}/var/named $1/altroot/var/named - InstallList ${ELWIX_BSDSRC} ${BSDSRC} $1/altroot/var/named - install -v ${FS_ETC}/resolv.safe $1/altroot/var/run/resolv.conf -} - -create_etc_motd() -{ - ELWIX_VER="ELWIX-${VERSION}_${TARGET_ARCH}"; - ELWIX_HDR_MOTD="${ELWIX_VER} :: Build date ${BUILD_DATE}"; - - awk -v fo="${1:-motd}" 'BEGIN { print "'"${ELWIX_HDR_MOTD}"'" > fo; } { print $0 >> fo; }' \ - ${CFGDIR}/elwix_signature.txt; -} - create_etc_fstab() { - cat >$1 <<_EOF -# Automatic generated fstab for ELWIX at ${BUILD_DATE} + cat >$1/etc/fstab <<_EOF +# Automatic generated fstab for ELWIX $2 at ${BUILD_DATE} # -/dev/ufs/elwix /elwix ufs ro 0 1 -md3 /tmp mfs rw,-s8m,-oasync,-S 0 0 -md4 /var mfs rw,-s16m,-S 0 0 _EOF } -mketc() +update_etc_cfexec() { - echo "+++ Build ELWIX FS etc directory ..." - InstallDir ${FS_ETC} $1/etc - - chown -R root:wheel $1/etc; - - chmod 0600 $1/etc/opieaccess; - chmod 0600 $1/etc/opiekeys; - - chmod 0600 $1/etc/master.passwd; - chmod 0600 $1/etc/spwd.db; - chmod 0600 $1/etc/ssh/ssh_host_dsa_key; - chmod 0600 $1/etc/ssh/ssh_host_key; - chmod 0600 $1/etc/ssh/ssh_host_rsa_key; - - chmod 0440 $1/etc/sudoers; - - chgrp www $1/etc/config.xml; - chmod 0660 $1/etc/config.xml; - - ln -sf /etc/rc.s $1/etc/rc.S - - ln -sf /usr/share/zoneinfo/${TIMEZONE} $1/etc/localtime; - ln -sf /usr/share/misc/termcap $1/etc/termcap; - - ln -sf /var/named/etc/namedb $1/etc/namedb; - ln -sf /var/run/resolv.conf $1/etc/resolv.conf; - - echo ${TARGET_ARCH} >$1/etc/platform; - - create_etc_motd $1/etc/motd; - create_etc_fstab $1/etc/fstab; + echo "mount = \"/elwix\"" >> $1/etc/cfexec.conf } -mkbackup() +install_fsdir() { - echo "+++ Build ELWIX FS backup factory default directory ..." - mkdir -p $1/altroot/backup + echo "+++ Install ELWIX RootFS $1 in bundle OS install file ..." + OSZ="" - cd $1 - tar -czf altroot/backup/.etc.tgz etc - cp -p etc/config.xml altroot/backup - cd altroot - tar -czf backup/.var.tgz var -} + install -v ${REL}/${ROOTFS_KERN} $1/boot/kernel/kernel.gz -mkhome() -{ - echo "+++ Build ELWIX FS root home directory ..." - install -d $1/root/.ssh - [ -r ${CFGDIR}/root.skel/ssh/authorized_keys2 ] && \ - install -v ${CFGDIR}/root.skel/ssh/authorized_keys2 $1/root/.ssh; + case "$2" in + [Ee][Xx][Tt]) + install -d $1/usr + cd $1/usr + pax -r -z -pe -f ${REL}/${ROMFS_IMG} + cd - - install -v ${CFGDIR}/root.skel/cshrc $1/root/.cshrc; - install -v ${CFGDIR}/root.skel/login $1/root/.login; - install -v ${CFGDIR}/root.skel/logout $1/root/.logout; - install -v ${CFGDIR}/root.skel/profile $1/root/.profile; - install -v ${CFGDIR}/root.skel/vimrc $1/root/.vimrc; -} + install -d $1/pkg + cd $1/pkg + pax -r -z -pe -f ${REL}/${ROMFS_IMG2} + cd - -install_fsdir() -{ - echo "+++ Install ELWIX FS in bundle OS install file ..." + OSZ=${REL}/${OS_EXT} + ;; + *) + install -v ${REL}/${ROMFS_IMG} \ + $1/altroot/elwix-firmware-${VERSION}_${TARGET_ARCH} + ln $1/altroot/elwix-firmware-${VERSION}_${TARGET_ARCH} \ + $1/altroot/${ROMFS_IMG} + ln -s /elwix/altroot/elwix-firmware-${VERSION}_${TARGET_ARCH} \ + $1/${ROMFS_IMG} - install -v ${REL}/${ROOTFS_KERN} ${FS}/boot/kernel + install -v ${REL}/${ROMFS_IMG2} \ + $1/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH} + ln $1/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH} \ + $1/altroot/${ROMFS_IMG2} + ln -s /elwix/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH} \ + $1/${ROMFS_IMG2} - install -v ${REL}/${ROMFS_IMG} ${FS}/elwix-firmware-${VERSION}_${TARGET_ARCH} - ln -s /elwix/elwix-firmware-${VERSION}_${TARGET_ARCH} ${FS}/${ROMFS_IMG} + OSZ=${REL}/${OS} + ;; + esac - cd $FS - tar -czvf ${REL}/${OS} . -} + cd $1 + tar -czvf $OSZ . -cleancvs() -{ - echo "+++ ELWIX clean CVS tags ..." - - find $1 -type d -name CVS -exec rm -rf {} \; >/dev/null 2>&1 + echo "+++ Completed ELWIX RootFS $1 --> $OSZ" } ### main() @@ -251,17 +138,32 @@ if [ ! -r ${REL}/${ROOTFS_KERN} -o ! -r ${REL}/${ROMFS exit 1 fi -clean_fsdir -build_fsdir +clean_fsdir ${FS} ${REL}/${OS} || exit 1 +clean_fsdir ${FS_EXT} ${REL}/${OS_EXT} || exit 1 -mkboot ${FS} -mkhome ${FS} -mkvar ${FS} -mketc ${FS} -cleancvs ${FS} -mkbackup ${FS} +build_fsdir ${FS} || exit 1 +build_fsdir ${FS_EXT} || exit 1 -install_fsdir +MakeFS_home ${FS} || exit 1 +MakeFS_home ${FS_EXT} || exit 1 -echo "+++ Complete build ELWIX FS" -echo "ELWIX finish version ${VERSION}, Good luck!" +MakeFS_var ${FS} ${FS_ETC} || exit 1 +MakeFS_var ${FS_EXT} ${FS_EXT_ETC} || exit 1 + +MakeFS_etc ${FS} ${FS_ETC} || exit 1 +MakeFS_etc ${FS_EXT} ${FS_EXT_ETC} ext || exit 1 + +create_etc_fstab ${FS} || exit 1 +create_etc_fstab ${FS_EXT} ext || exit 1 + +update_etc_cfexec ${FS} || exit 1 +update_etc_cfexec ${FS_EXT} ext || exit 1 + +MakeFS_boot ${FS} || exit 1 +MakeFS_boot ${FS_EXT} || exit 1 + +install_fsdir ${FS} || exit 1 +install_fsdir ${FS_EXT} ext || exit 1 + +echo "+++ Complete build ELWIX RootFS system" +echo "ELWIX RootFS finish version ${VERSION}, Good luck!"