Takuo Kitame | 2f8fef3 | 2010-07-02 02:01:15 +0900 | [diff] [blame] | 1 | #!/system/xbin/bash |
| 2 | # |
| 3 | # /system/xbin/openvpn-up.sh v0.2 |
| 4 | # |
| 5 | # Philip Freeman <philip.freeman@gmail.com> |
| 6 | # |
| 7 | # TODO: add support for grabbing search domains ? |
| 8 | # |
| 9 | # Changes: |
| 10 | #-- v0.2 |
| 11 | # - Added system logging |
| 12 | # - Fixed fome path issues |
| 13 | # |
| 14 | |
| 15 | LOG="/system/bin/log -t openvpn-up" |
| 16 | SETPROP=/system/bin/setprop |
| 17 | EXPR=/system/xbin/expr |
| 18 | stop=0 |
| 19 | dns_num=1 |
| 20 | i=0 |
| 21 | |
| 22 | ${LOG} "Starting..." |
| 23 | |
| 24 | eval opt=\$foreign_option_$i |
| 25 | |
| 26 | while [ ${stop} -eq 0 ]; do |
| 27 | if [ "`${EXPR} substr "$opt" 1 11`" = "dhcp-option" ]; then |
| 28 | if [ "`${EXPR} substr "$opt" 13 3`" = "DNS" ]; then |
| 29 | DNS="`${EXPR} substr "$opt" 17 1024`" |
| 30 | ${LOG} "Got DNS${dns_num}: ${DNS}" |
| 31 | if [ ${dns_num} -le 2 ]; then |
| 32 | #Set it |
| 33 | ${LOG} ${SETPROP} vpn.dns${dns_num} ${DNS} |
| 34 | ${SETPROP} vpn.dns${dns_num} ${DNS} |
| 35 | fi |
| 36 | dns_num=$(( ${dns_num}+1 )) |
| 37 | fi |
| 38 | fi |
| 39 | i=$(( $i+1 )) |
| 40 | eval opt=\$foreign_option_$i |
| 41 | if [ "$opt" = "" ]; then |
| 42 | stop=1 |
| 43 | fi |
| 44 | done |