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