Annotation of elwix/config/etc/rc.initial, revision 1.2.2.2
1.1 misho 1: #!/bin/sh
2: #
1.2 misho 3: # ELWIX Initial RC Menu script
1.1 misho 4: #
1.2.2.1 misho 5: # $Id: rc.initial,v 1.2 2012/10/12 08:22:44 misho Exp $
1.1 misho 6: #
7:
8: trap : 2
9: trap : 3
10: trap : 18
11: #exec </dev/console >/dev/console 2>/dev/console
1.2.2.1 misho 12: MAGIC_MENU="menu"
1.1 misho 13:
14: menu()
15: {
16: echo
17: echo
1.2 misho 18: echo "ELWIX - console setup"
1.1 misho 19: echo "*********************"
20: echo "0) Logout"
21: echo "1) Interfaces: assign network ports"
1.2.2.2 ! misho 22: echo "2) Reset root password"
1.1 misho 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: [ -r /etc/platform ] && PLATFORM=$(cat /etc/platform)
30: if [ "${PLATFORM}" != "embedded" ]; then
31: echo "9) Install on Hard Drive $PLATFORM";
32: fi
33: echo
34:
35: read -p "Enter number: " opcode
36:
37: case ${opcode} in
38: 0)
39: exit
40: ;;
41: 1)
1.2.2.2 ! misho 42: IFACES=$(ifconfig -l)
! 43: echo
! 44: echo "Available interfaces: $IFACES"
! 45: read -p " +Which from them: " iface
! 46: read -p " +Name of interface $iface []: " name
! 47: read -p " +Setup management vlan 4093 on $iface? [no|yes]: " mgmt
! 48: read -p " +IPv4 address/mask of interface $iface [dhcp|x.x.x.x/x]: " ip4
! 49: read -p " +IPv6 address/mask of interface $iface [auto|x:x:x::x/x]: " ip6
! 50: if [ X"$mgmt" = X"yes" -o X"$mgmt" = "y" ]; then
! 51: echo $iface >/etc/mylan
! 52: fi
! 53: ifconfig $iface description "$name" up
! 54: if [ -n "$ip4" ]; then
! 55: if [ X"$ip4" != X"dhcp" ]; then
! 56: ifconfig $iface inet alias $ip4
! 57: else
! 58: dhclient $iface
! 59: fi
! 60: fi
! 61: if [ -n "$ip6" ]; then
! 62: ifconfig $iface inet6 auto_linklocal -ifdisabled
! 63: if [ X"$ip6" != X"auto" ]; then
! 64: ifconfig $iface inet6 -accept_rtadv
! 65: ifconfig $iface inet6 alias $ip6
! 66: else
! 67: ifconfig $iface inet6 accept_rtadv
! 68: fi
! 69: fi
1.1 misho 70: ;;
71: 2)
1.2.2.2 ! misho 72: passwd root
1.1 misho 73: ;;
74: 3)
75: ;;
76: 4)
77: ;;
78: 5)
79: reboot
80: ;;
81: 6)
82: read -p " +Address: " host
83: read -p " +Number packets [4]: " cx
84: ping -n -c ${cx:-4} ${host:-localhost}
85: ;;
86: 7)
87: read -p " +Address: " host
88: read -p " +Port [22]: " port
89: read -p " +User [$USER]: " user
90: ssh -p ${port:-22} -l ${user:-$USER} ${host:-localhost}
91: ;;
92: 8)
93: $SHELL
94: ;;
95: 9)
96: ;;
97: esac
98: }
99:
100: ### main()
101:
102: while : ; do
103: if [ -r /etc/disablemenu ]; then
104: echo
105: echo
106: echo "*** Console menu disabled. ***"
107: echo
108:
109: stty -echo
110: read tmp
111: stty echo
112: if [ X"${tmp}" = X"${MAGIC_MENU}" ]; then
113: echo
114: echo "> OK, temporary unhide menu ..."
115: echo
116:
117: menu
118: fi
119: else
120: menu
121: fi
122: done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>