blob: 98bb439a552382868eec575a3d30512e5c950671 [file] [log] [blame]
Takuo Kitame2f8fef32010-07-02 02:01:15 +09001#!/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
15LOG="/system/bin/log -t openvpn-up"
16SETPROP=/system/bin/setprop
17EXPR=/system/xbin/expr
18stop=0
19dns_num=1
20i=0
21
22${LOG} "Starting..."
23
24eval opt=\$foreign_option_$i
25
26while [ ${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
44done