--- elwix/build_fs.sh 2013/01/27 23:20:15 1.4.2.2 +++ elwix/build_fs.sh 2013/07/31 14:57:01 1.7.2.7 @@ -5,7 +5,7 @@ # (C) AITNET ltd - Sofia/Bulgaria # by Michael Pounov # -# $Id: build_fs.sh,v 1.4.2.2 2013/01/27 23:20:15 misho Exp $ +# $Id: build_fs.sh,v 1.7.2.7 2013/07/31 14:57:01 misho Exp $ # [ -r ./config/rc.elwix ] && . ./config/rc.elwix @@ -30,22 +30,25 @@ if [ "${USER}" != "root" ]; then exit 1 fi -clean_fsdir() +clean_rel() { - echo "+++ Clean ELWIX FS ..." - rm -rf ${FS} ${FS_LITE} ${FS_LITE128} + echo "+++ Clean ELWIX OS release ..." + rm -rf $1 $2 - echo "+++ Clean ELWIX FS release ..." - rm -rf ${REL}/${OS} ${REL}/${OS_LITE} ${REL}/${OS_LITE128} + mkdir -p $1 + + if [ -d ${BASEFS} ]; then + cd ${BASEFS} + pax -rw -pe -X . $1 + cd - + fi } -build_fsdir() +build_vardir() { - echo "+++ Build ELWIX FS directory ..." - mkdir -p $1 + echo "+++ Build ELWIX altroot directory ..." cd $1 - # altroot install -d altroot; # altroot/var @@ -72,33 +75,16 @@ build_fsdir() 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; + ln -fs /tmp altroot/var/tmp; + chown -hR root:wheel . cd - } mkboot() { - echo "+++ Build ELWIX FS boot directory ..." + echo "+++ Build ELWIX OS boot directory ..." InstallDir ${WORLD}/boot $1/boot install -m 644 ${CFGDIR}/boot/boot.config $1; @@ -120,9 +106,7 @@ mkboot() mkvar() { - echo "+++ Build ELWIX FS var directory ..." - ln -s /tmp $1/altroot/var/tmp - + echo "+++ Build ELWIX OS var directory ..." touch $1/altroot/var/run/utmp touch $1/altroot/var/account/acct @@ -164,15 +148,15 @@ create_etc_fstab() cat >$1 <<_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 +/dev/ufs/elwix / ufs ro 0 1 +md2 /tmp mfs rw,-s8m,-oasync,-S 0 0 +md3 /var mfs rw,-s16m,-S 0 0 _EOF } mketc() { - echo "+++ Build ELWIX FS etc directory ..." + echo "+++ Build ELWIX OS etc directory ..." InstallDir ${FS_ETC} $1/etc chown -R root:wheel $1/etc; @@ -192,6 +176,7 @@ mketc() 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; @@ -217,7 +202,7 @@ mketc() mkbackup() { - echo "+++ Build ELWIX FS backup factory default directory ..." + echo "+++ Build ELWIX OS backup factory default directory ..." mkdir -p $1/altroot/backup cd $1 @@ -230,7 +215,7 @@ mkbackup() mkhome() { - echo "+++ Build ELWIX FS root home directory ..." + 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; @@ -242,50 +227,18 @@ mkhome() install -v ${CFGDIR}/root.skel/vimrc $1/root/.vimrc; } -install_fsdir() +install_rel() { - echo "+++ Install ELWIX FS $1 in bundle OS install file ..." + echo "+++ Install ELWIX OS $1 in bundle OS install file ..." OSZ="" - install -v ${REL}/${ROOTFS_KERN} $1/boot/kernel + install -v ${KERNEL} $1/boot/kernel; + cd $1/boot/kernel; + gzip -9 kernel; + cd -; case "$2" in - _[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_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 @@ -295,44 +248,14 @@ install_fsdir() } ### main() -if [ ! -r ${REL}/${ROOTFS_KERN} -o ! -r ${REL}/${ROMFS_IMG} ]; then - echo - echo "Error:: not found kernel or firmware elwix files ..." - echo - echo " For fix this issue, please re-run build_rootfs.sh or build_romfs.sh" - echo - exit 1 -fi - -clean_fsdir - -build_fsdir ${FS} -build_fsdir ${FS_LITE} -build_fsdir ${FS_LITE128} - +clean_rel ${FS} ${REL}/${OS} +build_vardir ${FS}/elwix +mkhome ${FS}/elwix +mkvar ${FS}/elwix +mketc ${FS}/elwix +mkbackup ${FS}/elwix mkboot ${FS} -mkboot ${FS_LITE} -mkboot ${FS_LITE128} +install_rel ${FS} -mkhome ${FS} -mkhome ${FS_LITE} -mkhome ${FS_LITE128} - -mkvar ${FS} -mkvar ${FS_LITE} -mkvar ${FS_LITE128} - -mketc ${FS} -mketc ${FS_LITE} "_lite" -mketc ${FS_LITE128} "_lite_128" - -mkbackup ${FS} -mkbackup ${FS_LITE} -mkbackup ${FS_LITE128} - -install_fsdir ${FS} -install_fsdir ${FS_LITE} "_lite" -install_fsdir ${FS_LITE128} "_lite_128" - -echo "+++ Complete build ELWIX FS" +echo "+++ Complete build ELWIX OS" echo "ELWIX finish version ${VERSION}, Good luck!"