--- elwix/config/etc/Attic/rc.initial 2012/10/12 08:22:44 1.2 +++ elwix/config/etc/Attic/rc.initial 2013/01/24 13:01:39 1.2.2.6 @@ -2,14 +2,14 @@ # # ELWIX Initial RC Menu script # -# $Id: rc.initial,v 1.2 2012/10/12 08:22:44 misho Exp $ +# $Id: rc.initial,v 1.2.2.6 2013/01/24 13:01:39 misho Exp $ # trap : 2 trap : 3 trap : 18 -#exec /dev/console 2>/dev/console -MAGIC_MENU="unhide menu, now!" +exec /dev/console 2>/dev/console +MAGIC_MENU="menu" menu() { @@ -19,17 +19,14 @@ menu() echo "*********************" echo "0) Logout" echo "1) Interfaces: assign network ports" - echo "2) Set up LAN IP address" + echo "2) Reset root password" echo "3) Reset webGUI password" echo "4) Reset to factory defaults" echo "5) Reboot system" echo "6) Ping host" echo "7) SSH to host" echo "8) Go to shell" - [ -r /etc/platform ] && PLATFORM=$(cat /etc/platform) - if [ "${PLATFORM}" != "embedded" ]; then - echo "9) Install on Hard Drive $PLATFORM"; - fi + echo "9) Clone system on other drive"; echo read -p "Enter number: " opcode @@ -39,12 +36,55 @@ menu() exit ;; 1) + IFACES=$(ifconfig -l) + echo + echo "Available interfaces: $IFACES" + read -p " +Which from them: " iface + read -p " +Name of interface $iface []: " name + read -p " +Setup management vlan 4093 on $iface? [no|yes]: " mgmt + read -p " +IPv4 address/mask of interface $iface [dhcp|x.x.x.x/x]: " ip4 + read -p " +IPv6 address/mask of interface $iface [auto|x:x:x::x/x]: " ip6 + if [ X"$mgmt" = X"yes" -o X"$mgmt" = "y" ]; then + cfexec sh -c "echo $iface >/etc/mylan" + fi + ifconfig $iface description "$name" up + if [ -n "$ip4" ]; then + if [ X"$ip4" != X"dhcp" ]; then + ifconfig $iface inet alias $ip4 + else + dhclient $iface + fi + fi + if [ -n "$ip6" ]; then + ifconfig $iface inet6 auto_linklocal -ifdisabled + if [ X"$ip6" != X"auto" ]; then + ifconfig $iface inet6 -accept_rtadv + ifconfig $iface inet6 alias $ip6 + else + ifconfig $iface inet6 accept_rtadv + fi + fi ;; 2) + passwd root ;; 3) + echo + read -p "New system webGUI password: " pass + read -p "Confirm system webGUI password: " confirm + if [ X"$pass" = X"$confirm" ]; then + cfexec xmler -s /elwix/system/password /elwix/etc/config.xml \ + $(md5 -qs "$pass") + else + echo "Error:: passwords are different ..." + fi ;; 4) + echo + echo "Restore factory defaults ..." + cfexec rm -rf /elwix/etc/rc.S /elwix/etc/rc.s /elwix/etc/rc.t + cfexec tar -xzpf /elwix/backup/.var.tgz -C /elwix/altroot + cfexec tar -xzpf /elwix/altroot/backup/.etc.tgz -C /elwix ;; 5) reboot @@ -64,6 +104,20 @@ menu() $SHELL ;; 9) + echo + camcontrol devlist + echo + read -p " +Select drive [like: ada1]: " dev + if [ -n "$dev" ]; then + if `disklabel $dev`; then + read -p " +This is right choice? [no|yes]: " ask + if [ X"$ask" = X"yes" -o X"$ask" = X"y" ]; then + sysctl -w kern.geom.debugflags=16 + dd if=/dev/ufs/elwix of=/dev/$dev + sysctl -w kern.geom.debugflags=0 + fi + fi + fi ;; esac }