Annotation of elwix/config/etc/uboot/rc.initial, revision 1.1.2.1
1.1.2.1 ! misho 1: #!/bin/sh
! 2: #
! 3: # ELWIX Initial RC Menu script
! 4: #
! 5: # $Id: rc.initial,v 1.6 2013/08/07 13:26:31 misho Exp $
! 6: #
! 7:
! 8: trap : 2
! 9: trap : 3
! 10: trap : 18
! 11: #exec </dev/console >/dev/console 2>/dev/console
! 12: MAGIC_MENU="menu"
! 13:
! 14: menu()
! 15: {
! 16: echo
! 17: echo
! 18: echo "ELWIX - console setup"
! 19: echo "*********************"
! 20: echo "0) Logout"
! 21: echo "1) Interfaces: assign network ports"
! 22: echo "2) Reset root password"
! 23: echo "3) Reset webGUI password"
! 24: echo "4) Reset to factory defaults"
! 25: echo "5) Reboot system"
! 26: echo "6) Ping host"
! 27: echo "7) SSH to host"
! 28: echo "8) Go to shell"
! 29: echo
! 30:
! 31: read -p "Enter number: " opcode
! 32:
! 33: case ${opcode} in
! 34: 0)
! 35: exit
! 36: ;;
! 37: 1)
! 38: IFACES=$(ifconfig -l)
! 39: echo
! 40: echo "Available interfaces: $IFACES"
! 41: read -p " +Which from them: " iface
! 42: if [ -z "$iface" ]; then
! 43: return 1
! 44: fi
! 45: read -p " +Name of interface $iface []: " name
! 46: read -p " +Setup management vlan 4093 on $iface? [no|yes]: " mgmt
! 47: read -p " +IPv4 address/mask of interface $iface [dhcp|x.x.x.x/x]: " ip4
! 48: read -p " +IPv6 address/mask of interface $iface [auto|x:x:x::x/x]: " ip6
! 49: if [ X"$mgmt" = X"yes" -o X"$mgmt" = X"y" ]; then
! 50: cfexec sh -c "echo $iface >/etc/mylan"
! 51: fi
! 52: ifconfig $iface description "$name" up
! 53: if [ -n "$ip4" ]; then
! 54: if [ X"$ip4" != X"dhcp" ]; then
! 55: ifconfig $iface inet alias $ip4
! 56: else
! 57: dhclient $iface
! 58: fi
! 59: fi
! 60: if [ -n "$ip6" ]; then
! 61: ifconfig $iface inet6 auto_linklocal -ifdisabled
! 62: if [ X"$ip6" != X"auto" ]; then
! 63: ifconfig $iface inet6 -accept_rtadv
! 64: ifconfig $iface inet6 alias $ip6
! 65: else
! 66: ifconfig $iface inet6 accept_rtadv
! 67: fi
! 68: fi
! 69: ;;
! 70: 2)
! 71: passwd root
! 72: ;;
! 73: 3)
! 74: echo
! 75: read -p "New system webGUI password: " pass
! 76: read -p "Confirm system webGUI password: " confirm
! 77: if [ X"$pass" = X"$confirm" ]; then
! 78: cfexec xmler -s /elwix/system/password /elwix/etc/config.xml \
! 79: $(md5 -qs "$pass")
! 80: else
! 81: echo "Error:: passwords are different ..."
! 82: fi
! 83: ;;
! 84: 4)
! 85: echo
! 86: echo "Restore factory defaults ..."
! 87: read -p " +Are you sure for restore and clear all changes? [no|yes]: " ans
! 88: if [ X"$ans" = X"yes" -o X"$ans" = X"y" ]; then
! 89: cfexec rm -rf /elwix/etc/rc.S /elwix/etc/rc.s /elwix/etc/rc.t
! 90: cfexec tar -xzpf /elwix/altroot/backup/.var.tgz -C /elwix/altroot
! 91: cfexec tar -xzpf /elwix/altroot/backup/.etc.tgz -C /elwix
! 92: fi
! 93: ;;
! 94: 5)
! 95: reboot
! 96: ;;
! 97: 6)
! 98: read -p " +Address: " host
! 99: read -p " +Number packets [4]: " cx
! 100: ping -n -c ${cx:-4} ${host:-localhost}
! 101: ;;
! 102: 7)
! 103: read -p " +Address: " host
! 104: read -p " +Port [22]: " port
! 105: read -p " +User [$USER]: " user
! 106: ssh -p ${port:-22} -l ${user:-$USER} ${host:-localhost}
! 107: ;;
! 108: 8)
! 109: exec $SHELL
! 110: ;;
! 111: esac
! 112: }
! 113:
! 114: ### main()
! 115:
! 116: while : ; do
! 117: if [ -r /etc/disablemenu ]; then
! 118: echo
! 119: echo
! 120: echo "*** Console menu disabled. ***"
! 121: echo
! 122:
! 123: stty -echo
! 124: read tmp
! 125: stty echo
! 126: if [ X"${tmp}" = X"${MAGIC_MENU}" ]; then
! 127: echo
! 128: echo "> OK, temporary unhide menu ..."
! 129: echo
! 130:
! 131: menu
! 132: fi
! 133: else
! 134: menu
! 135: fi
! 136: done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>