Return to rc.init CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / elwix / config / etc / default |
1.1 ! misho 1: #!/bin/sh ! 2: # ! 3: # Boot startup script for elwix :) ! 4: # ! 5: # $Id: rc,v 1.3.2.16 2010/08/14 23:14:15 misho Exp $ ! 6: ! 7: stty status '^T' ! 8: ! 9: trap : 2 ! 10: trap : 3 ! 11: trap : 18 ! 12: ! 13: HOME=/root ! 14: PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/pkg/bin:/usr/pkg/sbin:/usr/local/bin:/usr/local/sbin ! 15: TERM=xterm ! 16: BLOCKSIZE=1k ! 17: EDITOR=vi ! 18: PAGER=less ! 19: export HOME PATH TERM BLOCKSIZE EDITOR PAGER ! 20: ! 21: SYSPKGDIR="/system" ! 22: BOOTLOG="/var/run/elwix.boot" ! 23: XML="/etc/config.xml" ! 24: ! 25: umask 022 ! 26: ! 27: boot() ! 28: { ! 29: echo "Check and mount filesystems ..." ! 30: fsck -y 1>/dev/null 2>&1 && mount -a || fsck -f -y ! 31: ! 32: if [ -c /dev/ufs/fit2cf ]; then ! 33: echo "Check and mount if its exist fit2cf ..." ! 34: fsck -y -tufs /dev/ufs/fit2cf 1>/dev/null 2>&1 && mount -o ro /dev/ufs/fit2cf /elwix/cf || \ ! 35: fsck -f -y -tufs /dev/ufs/fit2cf ! 36: fi ! 37: ! 38: echo "Loading elwix firmware variables ..." ! 39: cd /elwix/altroot ! 40: pax -rw -pe var / ! 41: chmod 1777 /var/tmp ! 42: cd / ! 43: } ! 44: ! 45: options() ! 46: { ! 47: echo "Set firmware options ..." | tee -a $BOOTLOG ! 48: [ -x /etc/sysctl.conf ] && /etc/sysctl.conf | tee -a $BOOTLOG ! 49: } ! 50: ! 51: passwd() ! 52: { ! 53: echo "Syncing password database ..." | tee -a $BOOTLOG ! 54: pwd_mkdb /etc/master.passwd | tee -a $BOOTLOG 1>/dev/null 2>&1 ! 55: rm -f /etc/nologin ! 56: } ! 57: ! 58: local() ! 59: { ! 60: echo "Configurate localhost ..." | tee -a $BOOTLOG ! 61: ifconfig lo0 127.0.0.1 | tee -a $BOOTLOG 1>/dev/null 2>&1 ! 62: hostname `cat /etc/myname` ! 63: hostname `xmler -g /elwix/system/hostname $XML` ! 64: domainname `xmler -g /elwix/system/domain $XML` ! 65: } ! 66: ! 67: geteth() ! 68: { ! 69: ifconfig -a -u | awk ' ! 70: (match($0, "[:alpha:]*\: ") && match($2, "flags=")) { eth = substr($1, 1, index($1, ":") - 1); next; }; ! 71: (match($0, "media:\ Ethernet")) { printf("%s\n", eth); }; ! 72: ' | head -1 ! 73: } ! 74: ! 75: mgmt() ! 76: { ! 77: [ -r /etc/mylan ] && VDEV=`cat /etc/mylan` ! 78: VDEV=${VDEV:-`get1steth -g`} ! 79: ! 80: echo "Configurete management interface to ($VDEV) ..." | tee -a $BOOTLOG ! 81: get1steth -v $VDEV | tee -a $BOOTLOG 1>/dev/null 2>&1 ! 82: } ! 83: ! 84: syspkg() ! 85: { ! 86: echo "Setup elwix dynamic link libraries ..." ! 87: ldconfig /etc/ld.so.conf ! 88: ! 89: echo "Mounting firmware system packages:" | tee -a $BOOTLOG ! 90: # Raw images ! 91: for i in /elwix/cf/*-firmware; do ! 92: if [ -r $i ]; then ! 93: MDDEV=$(mdconfig -a -t vnode -f $i); ! 94: install -d $SYSPKGDIR/$MDDEV; ! 95: mount -r /dev/$MDDEV $SYSPKGDIR/$MDDEV | tee -a $BOOTLOG 1>/dev/null 2>&1; ! 96: if [ $? -ne 0 ]; then ! 97: mdconfig -d -u $MDDEV; ! 98: echo "Failed mount system package $i ... Corrupted!" | tee -a $BOOTLOG; ! 99: continue ! 100: else ! 101: echo "Added firmware system package ... $i($?)" | tee -a $BOOTLOG; ! 102: PATH=$PATH:$SYSPKGDIR/$MDDEV/bin:$SYSPKGDIR/$MDDEV/sbin ! 103: export PATH ! 104: ! 105: [ -d $SYSPKGDIR/$MDDEV/lib ] && ldconfig -v -m $SYSPKGDIR/$MDDEV/lib | \ ! 106: tee -a $BOOTLOG 1>/dev/null 2>&1; ! 107: ! 108: [ -x $SYSPKGDIR/$MDDEV/.pkg2sys ] && $SYSPKGDIR/$MDDEV/.pkg2sys; ! 109: fi ! 110: fi ! 111: done ! 112: # UZIP images ! 113: for i in /elwix/cf/*-firmware-pkg; do ! 114: if [ -r $i ]; then ! 115: MDDEV=$(mdconfig -a -t vnode -f $i); ! 116: install -d $SYSPKGDIR/$MDDEV; ! 117: mount -r /dev/$MDDEV.uzip $SYSPKGDIR/$MDDEV | tee -a $BOOTLOG 1>/dev/null 2>&1; ! 118: if [ $? -ne 0 ]; then ! 119: mdconfig -d -u $MDDEV; ! 120: echo "Failed mount system package $i ... Corrupted!" | tee -a $BOOTLOG; ! 121: continue ! 122: else ! 123: echo "Added firmware system package ... $i($?)" | tee -a $BOOTLOG; ! 124: PATH=$PATH:$SYSPKGDIR/$MDDEV/bin:$SYSPKGDIR/$MDDEV/sbin ! 125: export PATH ! 126: ! 127: [ -d $SYSPKGDIR/$MDDEV/lib ] && ldconfig -v -m $SYSPKGDIR/$MDDEV/lib | \ ! 128: tee -a $BOOTLOG 1>/dev/null 2>&1; ! 129: ! 130: [ -x $SYSPKGDIR/$MDDEV/.pkg2sys ] && $SYSPKGDIR/$MDDEV/.pkg2sys; ! 131: fi ! 132: fi ! 133: done ! 134: } ! 135: ! 136: service() ! 137: { ! 138: echo "Starting distribution static services:" | tee -a $BOOTLOG ! 139: for i in /etc/rc.d/*.run; do ! 140: if [ -x $i ]; then ! 141: $i ! 142: fi ! 143: done ! 144: ! 145: if [ -d /etc/rc.S ]; then ! 146: echo "Select boot service directory ..." `readlink /etc/rc.S` | tee -a $BOOTLOG ! 147: ! 148: echo "Starting distribution services:" | tee -a $BOOTLOG ! 149: for i in /etc/rc.S/*.run; do ! 150: if [ -x $i ]; then ! 151: $i ! 152: fi ! 153: done ! 154: fi ! 155: } ! 156: ! 157: # ! 158: ## main() ! 159: # ! 160: ! 161: boot ! 162: echo "elwix>>> Start system boot stage at `date`" | tee $BOOTLOG ! 163: options ! 164: passwd ! 165: local ! 166: mgmt ! 167: syspkg ! 168: service ! 169: echo "elwix>>> Start local services:" | tee -a $BOOTLOG ! 170: [ -r /etc/rc.local ] && . /etc/rc.local ! 171: echo "elwix>>> Done." | tee -a $BOOTLOG