--- elwix/build_fs.sh 2013/07/29 15:28:23 1.7.2.2 +++ elwix/build_fs.sh 2013/08/05 11:59:10 1.7.2.13 @@ -5,7 +5,7 @@ # (C) AITNET ltd - Sofia/Bulgaria # by Michael Pounov # -# $Id: build_fs.sh,v 1.7.2.2 2013/07/29 15:28:23 misho Exp $ +# $Id: build_fs.sh,v 1.7.2.13 2013/08/05 11:59:10 misho Exp $ # [ -r ./config/rc.elwix ] && . ./config/rc.elwix @@ -30,23 +30,19 @@ if [ "${USER}" != "root" ]; then exit 1 fi -clean_rel() +clean_fsdir() { - echo "+++ Clean ELWIX OS release ..." + echo "+++ Clean ELWIX FS ..." rm -rf $1 $2 - - mkdir -p $1 - - cd ${ROMFS} - pax -rw -pe -X . $1 - cd - } -build_vardir() +build_fsdir() { - echo "+++ Build ELWIX altroot directory ..." + echo "+++ Build ELWIX FS directory ..." + mkdir -p $1 cd $1 + # altroot install -d altroot; # altroot/var @@ -65,7 +61,6 @@ build_vardir() install -d -o 883 -g 883 altroot/var/mqtt; install -d altroot/var/named; install -d altroot/var/run; - install -d -m 1777 altroot/var/tmp; install -d altroot/var/sys; install -d -o 53 -g 53 altroot/var/run/named; install -d -o 101 -g 101 altroot/var/run/quagga; @@ -74,175 +69,85 @@ build_vardir() install -d -g 1 altroot/var/spool/lpd; install -d -g 1 altroot/var/spool/output; install -d -g 1 altroot/var/spool/output/lpd; +# boot + install -d boot; +# cf + install -d cf; +# etc + install -d etc; + install -d -o 883 -g 883 etc/mqtt; +# exports + install -d exports; +# home + install -d home; +# root + install -d -m 0700 root; +# pkg + install -d pkg; + install -d pkg/db; + install -d pkg/lib; +# tftpboot + install -d tftpboot; chown -hR root:wheel . cd - } -mkboot() -{ - echo "+++ Build ELWIX OS boot directory ..." - InstallDir ${WORLD}/boot $1/boot - - install -m 644 ${CFGDIR}/boot/boot.config $1; - - install -m 444 ${CFGDIR}/boot/beastie.4th $1/boot; - install -m 444 ${CFGDIR}/boot/brand.4th $1/boot; - install -m 444 ${CFGDIR}/boot/menu.4th $1/boot; - - install -m 444 ${KERNDEVHINTS} $1/boot/device.hints; - - 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 OS var directory ..." - touch $1/altroot/var/run/utmp - - touch $1/altroot/var/account/acct - - touch $1/altroot/var/log/elwix - touch $1/altroot/var/log/lastlog - touch $1/altroot/var/log/wifi.log - touch $1/altroot/var/log/utx.log - - 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/init.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$2-${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$2 at ${BUILD_DATE} + cat >$1/etc/fstab <<_EOF +# Automatic generated fstab for ELWIX $2 at ${BUILD_DATE} # -/dev/ufs/elwix / ufs ro 0 1 -md2 /var mfs rw,-s16m,-S 0 0 +/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() +install_fsdir() { - echo "+++ Build ELWIX OS 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 0600 $1/etc/ssh/ssh_host_ecdsa_key; - - chmod 0440 $1/etc/sudoers; - - chgrp 80 $1/etc/config.xml; - chmod 0660 $1/etc/config.xml; - - mkdir -p $1/etc/mqtt; - chgrp -R 883 $1/etc/mqtt; - chown -R 883 $1/etc/mqtt; - - 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; - - ln -sf /elwix/pkg/etc/mk.conf $1/etc/mk.conf; - - echo ${TARGET_ARCH} >$1/etc/platform; - - create_etc_motd $1/etc/motd $2; - create_etc_fstab $1/etc/fstab $2; - - echo "+++ ELWIX clean CVS tags ..." - CleanCVS $1 - CleanCVS $1/etc -} - -mkbackup() -{ - echo "+++ Build ELWIX OS backup factory default directory ..." - mkdir -p $1/altroot/backup - - cd $1 - cp -p etc/config.xml altroot/backup -# tar -czf altroot/backup/.etc.tgz etc - -# cd altroot -# tar -czf backup/.var.tgz var -} - -mkhome() -{ - echo "+++ Build ELWIX OS 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; - - 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_rel() -{ - echo "+++ Install ELWIX OS $1 in bundle OS install file ..." + echo "+++ Install ELWIX FS $1 in bundle OS install file ..." OSZ="" - install -v ${KERNEL} $1/boot/kernel; - cd $1/boot/kernel; - gzip -9 kernel; - cd -; + install -v ${REL}/${ROOTFS_KERN} $1/boot/kernel/kernel.gz case "$2" in - _128) + [Ll][Ii][Tt][Ee]_128) + install -d $1/usr + cd $1/usr + pax -r -z -pe -f ${REL}/${ROMFS_IMG} + cd - + install -d $1/usr/local cd $1/usr/local pax -r -z -pe -f ${REL}/${ROMFS_IMG2} cd - - OSZ=${REL}/${OS_128} + OSZ=${REL}/${OS_LITE128} ;; + [Ll][Ii][Tt][Ee]) + install -d $1/usr + cd $1/usr + pax -r -z -pe -f ${REL}/${ROMFS_IMG} + cd - + + OSZ=${REL}/${OS_LITE} + ;; *) + 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}/${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} + OSZ=${REL}/${OS} ;; esac @@ -261,29 +166,41 @@ if [ ! -r ${REL}/${ROOTFS_KERN} -o ! -r ${REL}/${ROMFS exit 1 fi -clean_rel ${FS} ${REL}/${OS} -clean_rel ${FS_128} ${REL}/${OS_128} +clean_fsdir ${FS} ${REL}/${OS} +clean_fsdir ${FS_LITE} ${REL}/${OS_LITE} +#clean_fsdir ${FS_LITE128} ${REL}/${OS_LITE128} -build_vardir ${FS}/elwix -build_vardir ${FS_128}/elwix +build_fsdir ${FS} +#build_fsdir ${FS_LITE} +#build_fsdir ${FS_LITE128} -mkhome ${FS}/elwix -mkhome ${FS_128}/elwix +MakeFS_home ${FS} +#MakeFS_home ${FS_LITE} +#MakeFS_home ${FS_LITE128} -mkvar ${FS}/elwix -mkvar ${FS_128}/elwix +MakeFS_var ${FS} ${FS_ETC} +#MakeFS_var ${FS_LITE} ${FS_ETC} +#MakeFS_var ${FS_LITE128} ${FS_ETC} -mketc ${FS}/elwix -mketc ${FS_128}/elwix +MakeFS_etc ${FS} ${FS_ETC} +#MakeFS_etc ${FS_LITE} ${FS_ETC} lite +#MakeFS_etc ${FS_LITE128} ${FS_ETC} lite_128 -mkbackup ${FS}/elwix -mkbackup ${FS_128}/elwix +create_etc_fstab ${FS} +#create_etc_fstab ${FS_LITE} lite +#create_etc_fstab ${FS_LITE128} lite_128 -mkboot ${FS} -mkboot ${FS_128} +MakeFS_backup ${FS} +#MakeFS_backup ${FS_LITE} +#MakeFS_backup ${FS_LITE128} -install_rel ${FS} -install_rel ${FS_128} _128 +MakeFS_boot ${FS} +#MakeFS_boot ${FS_LITE} +#MakeFS_boot ${FS_LITE128} -echo "+++ Complete build ELWIX OS" +install_fsdir ${FS} +#install_fsdir ${FS_LITE} lite +#install_fsdir ${FS_LITE128} lite_128 + +echo "+++ Complete build ELWIX FS" echo "ELWIX finish version ${VERSION}, Good luck!"