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