Annotation of elwix/config/etc/default/rc.initial, revision 1.1.2.5

1.1.2.1   misho       1: #!/bin/sh
                      2: #
                      3: # ELWIX Initial RC Menu script
                      4: #
1.1.2.5 ! misho       5: # $Id: rc.initial,v 1.1.2.4 2013/01/28 00:40:22 misho Exp $
1.1.2.1   misho       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 "9) Clone system on other drive";
                     30:        echo
                     31: 
                     32:        read -p "Enter number: " opcode
                     33: 
                     34:        case ${opcode} in
                     35:                0)
                     36:                        exit
                     37:                        ;;
                     38:                1)
                     39:                        IFACES=$(ifconfig -l)
                     40:                        echo
                     41:                        echo "Available interfaces: $IFACES"
                     42:                        read -p " +Which from them: " iface
1.1.2.5 ! misho      43:                        if [ -z "$iface" ]; then
        !            44:                                return 1
        !            45:                        fi
1.1.2.1   misho      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
1.1.2.4   misho      50:                        if [ X"$mgmt" = X"yes" -o X"$mgmt" = X"y" ]; then
1.1.2.1   misho      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:                        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
                     84:                        ;;
                     85:                4)
                     86:                        echo
                     87:                        echo "Restore factory defaults ..."
1.1.2.2   misho      88:                        read -p " +Are you sure for restore and clear all changes? [no|yes]: " ans
1.1.2.4   misho      89:                        if [ X"$ans" = X"yes" -o X"$ans" = X"y" ]; then
1.1.2.2   misho      90:                                cfexec rm -rf /elwix/etc/rc.S /elwix/etc/rc.s /elwix/etc/rc.t
1.1.2.3   misho      91:                                cfexec tar -xzpf /elwix/altroot/backup/.var.tgz -C /elwix/altroot
1.1.2.2   misho      92:                                cfexec tar -xzpf /elwix/altroot/backup/.etc.tgz -C /elwix
                     93:                        fi
1.1.2.1   misho      94:                        ;;
                     95:                5)
                     96:                        reboot
                     97:                        ;;
                     98:                6)
                     99:                        read -p " +Address: " host
                    100:                        read -p " +Number packets [4]: " cx
                    101:                        ping -n -c ${cx:-4} ${host:-localhost}
                    102:                        ;;
                    103:                7)
                    104:                        read -p " +Address: " host
                    105:                        read -p " +Port [22]: " port
                    106:                        read -p " +User [$USER]: " user
                    107:                        ssh -p ${port:-22} -l ${user:-$USER} ${host:-localhost}
                    108:                        ;;
                    109:                8)
                    110:                        $SHELL
                    111:                        ;;
                    112:                9)
                    113:                        echo
                    114:                        camcontrol devlist
                    115:                        echo
                    116:                        read -p " +Select drive [like: ada1]: " dev
                    117:                        if [ -n "$dev" ]; then
                    118:                                if `disklabel $dev`; then
                    119:                                        read -p " +This is right choice? [no|yes]: " ask
                    120:                                        if [ X"$ask" = X"yes" -o X"$ask" = X"y" ]; then
                    121:                                                sysctl -w kern.geom.debugflags=16
                    122:                                                dd if=/dev/ufs/elwix of=/dev/$dev
                    123:                                                sysctl -w kern.geom.debugflags=0
                    124:                                        fi
                    125:                                fi
                    126:                        fi
                    127:                        ;;
                    128:        esac
                    129: }
                    130: 
                    131: ### main()
                    132: 
                    133: while : ; do
                    134:        if [ -r /etc/disablemenu ]; then
                    135:                echo
                    136:                echo
                    137:                echo "*** Console menu disabled. ***"
                    138:                echo
                    139: 
                    140:                stty -echo
                    141:                read tmp
                    142:                stty echo
                    143:                if [ X"${tmp}" = X"${MAGIC_MENU}" ]; then
                    144:                        echo
                    145:                        echo "> OK, temporary unhide menu ..."
                    146:                        echo
                    147: 
                    148:                        menu
                    149:                fi
                    150:        else
                    151:                menu
                    152:        fi
                    153: done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>