Return to rc.init CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / elwix / config / etc / uboot |
1.2 ! misho 1: #!/bin/sh ! 2: # ! 3: # Boot startup script for elwix :) ! 4: # ! 5: # $Id: rc.init,v 1.1.2.7 2014/01/27 22:10:22 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="/var/frm" ! 22: BOOTLOG="/var/run/elwix.boot" ! 23: ! 24: MGMT_VLAN="4093" ! 25: MGMT_NAME="mgmt" ! 26: MGMT_ADDR="10.254.254.254/30" ! 27: ! 28: umask 022 ! 29: ! 30: boot() ! 31: { ! 32: echo "Check and mount filesystems ..." ! 33: fsck -y 1>/dev/null 2>&1 && mount -a || fsck -f -y ! 34: ! 35: echo "Loading elwix firmware variables ..." ! 36: cd /elwix/altroot ! 37: pax -rw -pe var / ! 38: chmod 1777 /var/tmp ! 39: mount /elwix/etc ! 40: cd / ! 41: } ! 42: ! 43: restore_uboot() ! 44: { ! 45: echo "Load configz from NAND ..." ! 46: /etc/rc.cfg load /etc ! 47: } ! 48: ! 49: options() ! 50: { ! 51: echo "Set firmware options ..." | tee -a $BOOTLOG ! 52: [ -x /etc/sysctl.conf ] && /etc/sysctl.conf | tee -a $BOOTLOG ! 53: } ! 54: ! 55: passwd() ! 56: { ! 57: echo "Syncing password database ..." | tee -a $BOOTLOG ! 58: # pwd_mkdb /etc/master.passwd | tee -a $BOOTLOG 1>/dev/null 2>&1 ! 59: rm -f /etc/nologin ! 60: } ! 61: ! 62: local() ! 63: { ! 64: echo "Configurate localhost ..." | tee -a $BOOTLOG ! 65: ifconfig lo0 127.0.0.1 | tee -a $BOOTLOG 1>/dev/null 2>&1 ! 66: hostname `cat /etc/myname` ! 67: } ! 68: ! 69: geteth() ! 70: { ! 71: ifconfig -a -u | awk ' ! 72: (match($0, "[:alpha:]*\: ") && match($2, "flags=")) { eth = substr($1, 1, index($1, ":") - 1); next; }; ! 73: (match($0, "media:\ Ethernet")) { printf("%s\n", eth); }; ! 74: ' | head -1 ! 75: } ! 76: ! 77: mgmt() ! 78: { ! 79: [ -r /etc/mylan ] && VDEV=`cat /etc/mylan` ! 80: if [ -x /usr/local/bin/get1steth ]; then ! 81: VDEV=${VDEV:-`get1steth -g`} ! 82: ! 83: get1steth -v $VDEV | tee -a $BOOTLOG 1>/dev/null 2>&1 ! 84: else ! 85: VDEV=${VDEV:-`geteth`} ! 86: ifconfig $VDEV up ! 87: ifconfig vlan$MGMT_VLAN create vlan $MGMT_VLAN vlandev $VDEV ! 88: ifconfig vlan$MGMT_VLAN name $MGMT_NAME ! 89: ifconfig $MGMT_NAME inet $MGMT_ADDR ! 90: fi ! 91: ! 92: echo "Configurete management interface to ($VDEV) ..." | tee -a $BOOTLOG ! 93: } ! 94: ! 95: syspkg() ! 96: { ! 97: echo "Setup elwix dynamic link libraries ..." ! 98: ldconfig /etc/ld.so.conf ! 99: ! 100: echo "Mounting firmware system packages:" | tee -a $BOOTLOG ! 101: # Raw images ! 102: for i in /elwix/cf/*-pkg.frm; do ! 103: if [ -r $i ]; then ! 104: MDDEV=$(mdconfig -a -t vnode -f $i); ! 105: install -d $SYSPKGDIR/$MDDEV; ! 106: mount -r /dev/$MDDEV $SYSPKGDIR/$MDDEV | tee -a $BOOTLOG 1>/dev/null 2>&1; ! 107: if [ $? -ne 0 ]; then ! 108: mdconfig -d -u $MDDEV; ! 109: echo "Failed mount system package $i ... Corrupted!" | tee -a $BOOTLOG; ! 110: continue ! 111: else ! 112: echo "Added firmware system package ... $i($?)" | tee -a $BOOTLOG; ! 113: PATH=$PATH:$SYSPKGDIR/$MDDEV/bin:$SYSPKGDIR/$MDDEV/sbin ! 114: export PATH ! 115: ! 116: [ -d $SYSPKGDIR/$MDDEV/lib ] && ldconfig -v -m $SYSPKGDIR/$MDDEV/lib | \ ! 117: tee -a $BOOTLOG 1>/dev/null 2>&1; ! 118: ! 119: [ -x $SYSPKGDIR/$MDDEV/.pkg2sys ] && $SYSPKGDIR/$MDDEV/.pkg2sys; ! 120: fi ! 121: fi ! 122: done ! 123: # UZIP images ! 124: for i in /elwix/cf/*-pkg.frz; do ! 125: if [ -r $i ]; then ! 126: MDDEV=$(mdconfig -a -t vnode -f $i); ! 127: install -d $SYSPKGDIR/$MDDEV; ! 128: mount -r /dev/$MDDEV.uzip $SYSPKGDIR/$MDDEV | tee -a $BOOTLOG 1>/dev/null 2>&1; ! 129: if [ $? -ne 0 ]; then ! 130: mdconfig -d -u $MDDEV; ! 131: echo "Failed mount system package $i ... Corrupted!" | tee -a $BOOTLOG; ! 132: continue ! 133: else ! 134: echo "Added firmware system package ... $i($?)" | tee -a $BOOTLOG; ! 135: PATH=$PATH:$SYSPKGDIR/$MDDEV/bin:$SYSPKGDIR/$MDDEV/sbin ! 136: export PATH ! 137: ! 138: [ -d $SYSPKGDIR/$MDDEV/lib ] && ldconfig -v -m $SYSPKGDIR/$MDDEV/lib | \ ! 139: tee -a $BOOTLOG 1>/dev/null 2>&1; ! 140: ! 141: [ -x $SYSPKGDIR/$MDDEV/.pkg2sys ] && $SYSPKGDIR/$MDDEV/.pkg2sys; ! 142: fi ! 143: fi ! 144: done ! 145: } ! 146: ! 147: service() ! 148: { ! 149: echo "Starting distribution static services:" | tee -a $BOOTLOG ! 150: for i in /etc/rc.d/*.run; do ! 151: if [ -x $i ]; then ! 152: $i ! 153: fi ! 154: done ! 155: ! 156: if [ -d /etc/rc.S ]; then ! 157: echo "Select boot service directory ..." `readlink /etc/rc.S` | tee -a $BOOTLOG ! 158: ! 159: echo "Starting distribution services:" | tee -a $BOOTLOG ! 160: for i in /etc/rc.S/*.run; do ! 161: if [ -x $i ]; then ! 162: $i ! 163: fi ! 164: done ! 165: fi ! 166: } ! 167: ! 168: # ! 169: ## main() ! 170: # ! 171: ! 172: boot ! 173: restore_uboot ! 174: echo "elwix>>> Start system boot stage at `date`" | tee $BOOTLOG ! 175: options ! 176: passwd ! 177: local ! 178: mgmt ! 179: syspkg ! 180: service ! 181: echo "elwix>>> Start local services:" | tee -a $BOOTLOG ! 182: [ -r /etc/rc.local ] && . /etc/rc.local ! 183: echo "elwix>>> Done." | tee -a $BOOTLOG