|
version 1.7.2.7, 2013/07/31 14:57:01
|
version 1.11.2.5, 2017/06/20 08:49:03
|
|
Line 30 if [ "${USER}" != "root" ]; then
|
Line 30 if [ "${USER}" != "root" ]; then
|
| exit 1 |
exit 1 |
| fi |
fi |
| |
|
| clean_rel() | clean_fsdir() |
| { |
{ |
| echo "+++ Clean ELWIX OS release ..." | echo "+++ Clean ELWIX FS ... $1" |
| | chflags -Rf nosunlink $1 |
| rm -rf $1 $2 |
rm -rf $1 $2 |
| |
|
| mkdir -p $1 |
|
| |
|
| if [ -d ${BASEFS} ]; then |
|
| cd ${BASEFS} |
|
| pax -rw -pe -X . $1 |
|
| cd - |
|
| fi |
|
| } |
} |
| |
|
| build_vardir() | build_fsdir() |
| { |
{ |
| echo "+++ Build ELWIX altroot directory ..." | # |
| | # Structure of ELWIX CF Drive mount on /elwix |
| | # |
| | echo "+++ Build ELWIX FS directory ... $1" |
| | mkdir -p $1 |
| |
|
| cd $1 |
cd $1 |
| # altroot | # boot |
| install -d altroot; | install -d boot; |
| # altroot/var | # cf |
| install -d altroot/var; | install -d cf; |
| install -d altroot/var/account; | case ${TARGET} in |
| install -d altroot/var/at; | i386|amd64) |
| install -d altroot/var/at/jobs; | ln -fs /dev/ada0g cf/map.cfg |
| install -d altroot/var/at/spool; | ;; |
| install -d -g 63 -m 0770 altroot/var/authpf; | mips) |
| install -d -m 0750 altroot/var/cron; | ln -fs /dev/map/cfg cf/map.cfg |
| install -d -m 0700 altroot/var/cron/tabs; | ;; |
| install -d altroot/var/db; | esac |
| install -d -m 0555 altroot/var/empty; | # etc |
| install -d altroot/var/log; | install -d etc; |
| install -d -o 101 -g 101 altroot/var/log/quagga; | # exports |
| install -d -o 883 -g 883 altroot/var/mqtt; | install -d exports; |
| install -d altroot/var/named; | # home |
| install -d altroot/var/run; | install -d home; |
| install -d altroot/var/sys; | # local |
| install -d -o 53 -g 53 altroot/var/run/named; | install -d local; |
| install -d -o 101 -g 101 altroot/var/run/quagga; | # root |
| install -d altroot/var/spool; | install -d -m 0750 root; |
| install -d -o 66 -g 68 -m 0775 altroot/var/spool/lock; | # pkg |
| install -d -g 1 altroot/var/spool/lpd; | install -d pkg; |
| install -d -g 1 altroot/var/spool/output; | # tftpboot |
| install -d -g 1 altroot/var/spool/output/lpd; | install -d tftpboot; |
| |
|
| ln -fs /tmp altroot/var/tmp; |
|
| |
|
| chown -hR root:wheel . |
chown -hR root:wheel . |
| cd - |
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() |
create_etc_fstab() |
| { |
{ |
| cat >$1 <<_EOF | cat >$1/etc/fstab <<_EOF |
| # Automatic generated fstab for ELWIX$2 at ${BUILD_DATE} | # Automatic generated fstab for ELWIX $2 at ${BUILD_DATE} |
| # |
# |
| /dev/ufs/elwix / ufs ro 0 1 | /dev/ufs/elwix /elwix ufs ro 0 1 |
| md2 /tmp mfs rw,-s8m,-oasync,-S 0 0 | |
| md3 /var mfs rw,-s16m,-S 0 0 | |
| _EOF |
_EOF |
| } |
} |
| |
|
| mketc() | update_etc_cfexec() |
| { |
{ |
| echo "+++ Build ELWIX OS etc directory ..." | echo "mount = \"/elwix\"" >> $1/etc/cfexec.conf |
| InstallDir ${FS_ETC} $1/etc | } |
| |
|
| chown -R root:wheel $1/etc; | install_fsdir() |
| | { |
| | echo "+++ Install ELWIX RootFS $1 in bundle OS install file ..." |
| | OSZ="" |
| |
|
| chmod 0600 $1/etc/opieaccess; | install -v ${REL}/${ROOTFS_KERN} $1/boot/kernel/kernel.gz |
| chmod 0600 $1/etc/opiekeys; | |
| |
|
| chmod 0600 $1/etc/master.passwd; | case "$2" in |
| chmod 0600 $1/etc/spwd.db; | [Ee][Xx][Tt]) |
| chmod 0600 $1/etc/ssh/ssh_host_dsa_key; | install -d $1/usr |
| chmod 0600 $1/etc/ssh/ssh_host_key; | cd $1/usr |
| chmod 0600 $1/etc/ssh/ssh_host_rsa_key; | pax -r -z -pe -f ${REL}/${ROMFS_IMG} |
| chmod 0600 $1/etc/ssh/ssh_host_ecdsa_key; | cd - |
| |
|
| chmod 0440 $1/etc/sudoers; | install -d $1/pkg |
| | cd $1/pkg |
| | pax -r -z -pe -f ${REL}/${ROMFS_IMG2} |
| | cd - |
| |
|
| chgrp 80 $1/etc/config.xml; | OSZ=${REL}/${OS_EXT} |
| chmod 0660 $1/etc/config.xml; | ;; |
| | *) |
| | 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} |
| |
|
| mkdir -p $1/etc/mqtt; | install -v ${REL}/${ROMFS_IMG2} \ |
| chgrp -R 883 $1/etc/mqtt; | $1/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH} |
| chown -R 883 $1/etc/mqtt; | ln $1/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH} \ |
| | $1/altroot/${ROMFS_IMG2} |
| | ln -s /elwix/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH} \ |
| | $1/${ROMFS_IMG2} |
| |
|
| ln -sf /etc/rc.s $1/etc/rc.S | OSZ=${REL}/${OS} |
| | ;; |
| | esac |
| |
|
| ln -sf /usr/share/zoneinfo/${TIMEZONE} $1/etc/localtime; | cd $1 |
| ln -sf /usr/share/misc/termcap $1/etc/termcap; | tar -czvf $OSZ . |
| |
|
| ln -sf /var/named/etc/namedb $1/etc/namedb; | echo "+++ Completed ELWIX RootFS $1 --> $OSZ" |
| 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() | ### main() |
| { | if [ ! -r ${REL}/${ROOTFS_KERN} -o ! -r ${REL}/${ROMFS_IMG} ]; then |
| echo "+++ Build ELWIX OS backup factory default directory ..." | echo |
| mkdir -p $1/altroot/backup | 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 |
| |
|
| cd $1 | clean_fsdir ${FS} ${REL}/${OS} || exit 1 |
| cp -p etc/config.xml altroot/backup | clean_fsdir ${FS_EXT} ${REL}/${OS_EXT} || exit 1 |
| tar -czf altroot/backup/.etc.tgz etc | |
| |
|
| cd altroot | build_fsdir ${FS} || exit 1 |
| tar -czf backup/.var.tgz var | build_fsdir ${FS_EXT} || exit 1 |
| } | |
| |
|
| mkhome() | MakeFS_home ${FS} || exit 1 |
| { | MakeFS_home ${FS_EXT} || exit 1 |
| 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; | MakeFS_var ${FS} ${FS_ETC} || exit 1 |
| install -v ${CFGDIR}/root.skel/login $1/root/.login; | MakeFS_var ${FS_EXT} ${FS_EXT_ETC} || exit 1 |
| 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() | MakeFS_etc ${FS} ${FS_ETC} || exit 1 |
| { | MakeFS_etc ${FS_EXT} ${FS_EXT_ETC} ext || exit 1 |
| echo "+++ Install ELWIX OS $1 in bundle OS install file ..." | |
| OSZ="" | |
| |
|
| install -v ${KERNEL} $1/boot/kernel; | create_etc_fstab ${FS} || exit 1 |
| cd $1/boot/kernel; | create_etc_fstab ${FS_EXT} ext || exit 1 |
| gzip -9 kernel; | |
| cd -; | |
| |
|
| case "$2" in | update_etc_cfexec ${FS} || exit 1 |
| *) | update_etc_cfexec ${FS_EXT} ext || exit 1 |
| OSZ=${REL}/${OS} | |
| ;; | |
| esac | |
| |
|
| cd $1 | MakeFS_boot ${FS} || exit 1 |
| tar -czvf $OSZ . | MakeFS_boot ${FS_EXT} || exit 1 |
| } | |
| |
|
| ### main() | install_fsdir ${FS} || exit 1 |
| clean_rel ${FS} ${REL}/${OS} | install_fsdir ${FS_EXT} ext || exit 1 |
| build_vardir ${FS}/elwix | |
| mkhome ${FS}/elwix | |
| mkvar ${FS}/elwix | |
| mketc ${FS}/elwix | |
| mkbackup ${FS}/elwix | |
| mkboot ${FS} | |
| install_rel ${FS} | |
| |
|
| echo "+++ Complete build ELWIX OS" | echo "+++ Complete build ELWIX RootFS system" |
| echo "ELWIX finish version ${VERSION}, Good luck!" | echo "ELWIX RootFS finish version ${VERSION}, Good luck!" |