--- elwix/build_fs.sh 2011/07/25 13:03:51 1.1.2.5 +++ elwix/build_fs.sh 2013/07/31 13:56:23 1.7.2.6 @@ -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.7.2.6 2013/07/31 13:56:23 misho Exp $ # [ -r ./config/rc.elwix ] && . ./config/rc.elwix @@ -30,22 +30,23 @@ if [ "${USER}" != "root" ]; then exit 1 fi -clean_fsdir() +clean_rel() { - echo "+++ Clean ELWIX FS ..." - rm -rf ${FS} + echo "+++ Clean ELWIX OS release ..." + rm -rf $1 $2 - echo "+++ Clean ELWIX FS release ..." - rm -rf ${REL}/${OS} + mkdir -p $1 + + cd ${ROMFS} + pax -rw -pe -X . $1 + cd - } -build_fsdir() +build_vardir() { - echo "+++ Build ELWIX FS directory ..." - mkdir -p ${FS} + echo "+++ Build ELWIX altroot directory ..." - cd ${FS} - + cd $1 # altroot install -d altroot; # altroot/var @@ -54,54 +55,44 @@ build_fsdir() 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 -g 63 -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 -o 101 -g 101 altroot/var/log/quagga; + install -d -o 883 -g 883 altroot/var/mqtt; 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/sys; + install -d -o 53 -g 53 altroot/var/run/named; + install -d -o 101 -g 101 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; -# boot - install -d boot; -# cf - install -d cf; -# etc - install -d etc; -# exports - install -d exports; -# home - install -d home; -# root - install -d -m 0700 root; -# local - install -d local; -# tftpboot - install -d tftpboot; + install -d -o 66 -g 68 -m 0775 altroot/var/spool/lock; + 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; + 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; - install -m 644 ${CFGDIR}/boot/beastie.4th $1/boot; - install -m 644 ${CFGDIR}/boot/brand.4th $1/boot; + 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 @@ -113,20 +104,21 @@ 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 + 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/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 @@ -142,7 +134,7 @@ mkvar() create_etc_motd() { - ELWIX_VER="ELWIX-${VERSION}_${TARGET_ARCH}"; + 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; }' \ @@ -152,17 +144,17 @@ create_etc_motd() create_etc_fstab() { cat >$1 <<_EOF -# Automatic generated fstab for ELWIX at ${BUILD_DATE} +# 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; @@ -175,12 +167,17 @@ mketc() 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 www $1/etc/config.xml; + 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; @@ -189,27 +186,34 @@ mketc() 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; - create_etc_fstab $1/etc/fstab; + 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 FS backup factory default directory ..." + echo "+++ Build ELWIX OS backup factory default directory ..." mkdir -p $1/altroot/backup cd $1 - tar -czf altroot/backup/.etc.tgz etc 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 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; @@ -221,24 +225,32 @@ mkhome() install -v ${CFGDIR}/root.skel/vimrc $1/root/.vimrc; } -install_fsdir() +install_rel() { - echo "+++ Install ELWIX FS in bundle OS install file ..." + echo "+++ Install ELWIX OS $1 in bundle OS install file ..." + OSZ="" - install -v ${REL}/${ROOTFS_KERN} ${FS}/boot/kernel + install -v ${KERNEL} $1/boot/kernel; + cd $1/boot/kernel; + gzip -9 kernel; + cd -; - install -v ${REL}/${ROMFS_IMG} ${FS}/elwix-firmware-${VERSION}_${TARGET_ARCH} - ln -s /elwix/elwix-firmware-${VERSION}_${TARGET_ARCH} ${FS}/${ROMFS_IMG} + case "$2" in + _128) + install -d $1/usr/local + cd $1/usr/local + pax -r -z -pe -f ${REL}/${ROMFS_IMG2} + cd - - cd $FS - tar -czvf ${REL}/${OS} . -} + OSZ=${REL}/${OS_128} + ;; + *) + OSZ=${REL}/${OS} + ;; + esac -cleancvs() -{ - echo "+++ ELWIX clean CVS tags ..." - - find $1 -type d -name CVS -exec rm -rf {} \; >/dev/null 2>&1 + cd $1 + tar -czvf $OSZ . } ### main() @@ -251,17 +263,14 @@ if [ ! -r ${REL}/${ROOTFS_KERN} -o ! -r ${REL}/${ROMFS exit 1 fi -clean_fsdir -build_fsdir - +clean_rel ${FS} ${REL}/${OS} +build_vardir ${FS}/elwix +mkhome ${FS}/elwix +mkvar ${FS}/elwix +mketc ${FS}/elwix +mkbackup ${FS}/elwix mkboot ${FS} -mkhome ${FS} -mkvar ${FS} -mketc ${FS} -cleancvs ${FS} -mkbackup ${FS} +install_rel ${FS} -install_fsdir - -echo "+++ Complete build ELWIX FS" +echo "+++ Complete build ELWIX OS" echo "ELWIX finish version ${VERSION}, Good luck!"