pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

pastebin private pastebin - collaborative debugging tool What's a private pastebin?

Posted by fb on Wed 22nd Oct 11:03
download | new post

  1. #!/bin/bash
  2. #
  3. # Parses DHCP options from openvpn to update resolv.conf
  4. # To use set as 'up' and 'down' script in your openvpn *.conf:
  5. # up /etc/openvpn/update-resolv-conf
  6. # down /etc/openvpn/update-resolv-conf
  7. #
  8. # Used snippets of resolvconf script by Thomas Hood <jdthood@yahoo.co.uk>
  9. # and Chris Hanson
  10. # Licensed under the GNU GPL.  See /usr/share/common-licenses/GPL.
  11. #
  12. # 05/2006 chlauber@bnc.ch
  13. #
  14. # Example envs set from openvpn:
  15. foreign_option_1='dhcp-option DNS 10.1.1.10'
  16. # foreign_option_2='dhcp-option DNS 193.43.27.133'
  17. # foreign_option_3='dhcp-option DOMAIN be.bnc.ch'
  18.  
  19. [ -x /sbin/resolvconf ] || exit 0
  20. logger "This was a triumph"
  21. case $script_type in
  22.  
  23. up)
  24.         for optionname in ${!foreign_option_*} ; do
  25.                 option="${!optionname}"
  26.                 echo $option
  27.                 part1=$(echo "$option" | cut -d " " -f 1)
  28.                 if [ "$part1" == "dhcp-option" ] ; then
  29.                         part2=$(echo "$option" | cut -d " " -f 2)
  30.                         part3=$(echo "$option" | cut -d " " -f 3)
  31.                         if [ "$part2" == "DNS" ] ; then
  32.                                 IF_DNS_NAMESERVERS="$IF_DNS_NAMESERVERS $part3"
  33.                         fi
  34.                         if [ "$part2" == "DOMAIN" ] ; then
  35.                                 IF_DNS_SEARCH="$part3"
  36.                         fi
  37.                 fi
  38.         done
  39.         R=""
  40.         if [ "$IF_DNS_SEARCH" ] ; then
  41.                 R="${R}search $IF_DNS_SEARCH
  42. "
  43.         fi
  44.         for NS in $IF_DNS_NAMESERVERS ; do
  45.                 R="${R}nameserver $NS
  46. "
  47.         done
  48.         echo -n "$R" | /sbin/resolvconf -a "${dev}.inet"
  49.         logger "Stuff just happened"
  50.         ;;
  51. down)
  52.         /sbin/resolvconf -d "${dev}.inet"
  53.         ;;
  54. esac

Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Use syntax highlighting

To highlight particular lines, prefix each line with @@


Remember my settings