Advertisement
s243a

showStaticIPWindow() - Network Wizard - Puppylinux

Nov 27th, 2016
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.10 KB | None | 0 0
  1. showStaticIPWindow()
  2. {
  3.     IP_ADDRESS="$(ifconfig $INTERFACE | grep 'inet addr' | sed 's/.*inet addr://' | cut -d" " -f1)"
  4.     NETMASK="$(ifconfig $INTERFACE | grep 'inet addr' | sed 's/.*Mask://')"
  5.     GATEWAY="$(iproute | grep default | cut -d" " -f3)"
  6.     # get current dns servers
  7.     NUM=1
  8.     while read A B ; do
  9.       if [ "$A" = "nameserver" ] && dotquad "$B" ; then # being really paranoid...
  10.         eval DNS_SERVER$NUM="$B"
  11.         NUM=$((NUM+1))
  12.       fi
  13.     done<<EOF
  14. $( grep -m2 nameserver /etc/resolv.conf )
  15. EOF
  16.  
  17.     EXIT=""
  18.     while true
  19.     do
  20.         buildStaticIPWindow
  21.         I=$IFS; IFS=""
  22.         for STATEMENT in  $(gtkdialog3 --program NETWIZ_Static_IP_Window); do
  23.             eval $STATEMENT
  24.         done
  25.         IFS=$I
  26.         clean_up_gtkdialog NETWIZ_Static_IP_Window
  27.         unset NETWIZ_Static_IP_Window
  28.  
  29.         case "$EXIT" in
  30.             abort|Cancel) # close window
  31.                 break
  32.                 ;; # Do Nothing, It will exit without doing anything
  33.             #"21" ) # Help
  34.                 #showHelp
  35.                 #;;
  36.             "OK" ) # OK
  37.                 if validateStaticIP ; then
  38.                     setupStaticIP || EXIT=""
  39.                 else
  40.                     EXIT=""
  41.                 fi
  42.                 break
  43.                 ;;
  44.         esac
  45.     done
  46.  
  47.     if [ "${EXIT}" = "OK" ] ; then
  48.         return 0
  49.     else
  50.         return 1
  51.     fi
  52. } # end showStaticIPWindow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement