Annotation of elwix/config/etc/rc.initial, revision 1.2.2.5
1.1 misho 1: #!/bin/sh
2: #
1.2 misho 3: # ELWIX Initial RC Menu script
1.1 misho 4: #
1.2.2.5 ! misho 5: # $Id: rc.initial,v 1.2.2.4 2013/01/23 16:42:26 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
1.2.2.3 misho 31: echo "9) Clone system on other drive";
1.1 misho 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
1.2.2.3 misho 51: cfexec sh -c "echo $iface >/etc/mylan"
1.2.2.2 misho 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)
1.2.2.5 ! misho 75: echo
! 76: read -p "New system webGUI password: " pass
! 77: read -p "Confirm system webGUI password: " confirm
! 78: if [ X"$pass" = X"$confirm" ]; then
! 79: cfexec xmler -s /elwix/system/password /elwix/etc/config.xml \
! 80: $(md5 -qs "$pass")
! 81: else
! 82: echo "Error:: passwords are different ..."
! 83: fi
1.1 misho 84: ;;
85: 4)
1.2.2.3 misho 86: echo
87: echo "Restore factory defaults ..."
88: cfexec rm -rf /elwix/etc/rc.S /elwix/etc/rc.s /elwix/etc/rc.t
89: cfexec tar -xzpf /elwix/backup/.var.tgz -C /elwix/altroot
90: cfexec tar -xzpf /elwix/altroot/backup/.etc.tgz -C /elwix
1.1 misho 91: ;;
92: 5)
93: reboot
94: ;;
95: 6)
96: read -p " +Address: " host
97: read -p " +Number packets [4]: " cx
98: ping -n -c ${cx:-4} ${host:-localhost}
99: ;;
100: 7)
101: read -p " +Address: " host
102: read -p " +Port [22]: " port
103: read -p " +User [$USER]: " user
104: ssh -p ${port:-22} -l ${user:-$USER} ${host:-localhost}
105: ;;
106: 8)
107: $SHELL
108: ;;
109: 9)
1.2.2.3 misho 110: echo
111: camcontrol devlist
112: echo
113: read -p " +Select drive [like: ada1]: " dev
114: if [ -n "$dev" ]; then
115: if `disklabel $dev`; then
116: read -p " +This is right choice? [no|yes]: " ask
117: if [ X"$ask" = X"yes" -o X"$ask" = X"y" ]; then
1.2.2.4 misho 118: sysctl -w kern.geom.debugflags=16
119: dd if=/dev/ufs/elwix of=/dev/$dev
120: sysctl -w kern.geom.debugflags=0
1.2.2.3 misho 121: fi
122: fi
123: fi
1.1 misho 124: ;;
125: esac
126: }
127:
128: ### main()
129:
130: while : ; do
131: if [ -r /etc/disablemenu ]; then
132: echo
133: echo
134: echo "*** Console menu disabled. ***"
135: echo
136:
137: stty -echo
138: read tmp
139: stty echo
140: if [ X"${tmp}" = X"${MAGIC_MENU}" ]; then
141: echo
142: echo "> OK, temporary unhide menu ..."
143: echo
144:
145: menu
146: fi
147: else
148: menu
149: fi
150: done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>