1: #!/bin/sh
2: #
3: # ELWIX Initial RC Menu script
4: #
5: # $Id: rc.initial,v 1.2.2.3 2013/01/23 15:00:39 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: [ -r /etc/platform ] && PLATFORM=$(cat /etc/platform)
30: if [ "${PLATFORM}" != "embedded" ]; then
31: echo "9) Clone system on other drive";
32: fi
33: echo
34:
35: read -p "Enter number: " opcode
36:
37: case ${opcode} in
38: 0)
39: exit
40: ;;
41: 1)
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: cfexec sh -c "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
70: ;;
71: 2)
72: passwd root
73: ;;
74: 3)
75: ;;
76: 4)
77: echo
78: echo "Restore factory defaults ..."
79: cfexec rm -rf /elwix/etc/rc.S /elwix/etc/rc.s /elwix/etc/rc.t
80: cfexec tar -xzpf /elwix/backup/.var.tgz -C /elwix/altroot
81: cfexec tar -xzpf /elwix/altroot/backup/.etc.tgz -C /elwix
82: ;;
83: 5)
84: reboot
85: ;;
86: 6)
87: read -p " +Address: " host
88: read -p " +Number packets [4]: " cx
89: ping -n -c ${cx:-4} ${host:-localhost}
90: ;;
91: 7)
92: read -p " +Address: " host
93: read -p " +Port [22]: " port
94: read -p " +User [$USER]: " user
95: ssh -p ${port:-22} -l ${user:-$USER} ${host:-localhost}
96: ;;
97: 8)
98: $SHELL
99: ;;
100: 9)
101: echo
102: camcontrol devlist
103: echo
104: read -p " +Select drive [like: ada1]: " dev
105: if [ -n "$dev" ]; then
106: if `disklabel $dev`; then
107: read -p " +This is right choice? [no|yes]: " ask
108: if [ X"$ask" = X"yes" -o X"$ask" = X"y" ]; then
109: echo work .....
110: fi
111: fi
112: fi
113: ;;
114: esac
115: }
116:
117: ### main()
118:
119: while : ; do
120: if [ -r /etc/disablemenu ]; then
121: echo
122: echo
123: echo "*** Console menu disabled. ***"
124: echo
125:
126: stty -echo
127: read tmp
128: stty echo
129: if [ X"${tmp}" = X"${MAGIC_MENU}" ]; then
130: echo
131: echo "> OK, temporary unhide menu ..."
132: echo
133:
134: menu
135: fi
136: else
137: menu
138: fi
139: done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>