Merge pull request #5 from anrip/devel

Fixed some issues in Ubuntu
This commit is contained in:
ProfFan committed 2016-03-23 19:50:08 +08:00
commit e3531a8fbe
3 files changed
+88 -16

No files matched your search

+23 -5
View File
@@ -2,6 +2,26 @@
基于DNSPod用户API实现的纯Shell动态域名客户端,适配网卡地址。
# Usage
复制`dns.conf.example`到同一目录下的`dns.conf`并根据你的配置修改即可。
执行时直接运行`ddnspod.sh`,支持cron任务。
配置文件格式:
```
# 安全起见,不推荐使用密码认证
# arMail="test@gmail.com"
# arPass="123"
# 推荐使用Token认证
# 按`TokenID,Token`格式填写
arToken="12345,7676f344eaeaea9074c123451234512d"
# 每行一个域名
arDdnsCheck "test.org" "subdomain"
```
# 最近更新
2015/2/24
@@ -15,11 +35,9 @@
- 加入Mac支持
- sed脚本POSIX化,可跨平台
# Issue
- [x] Mac下sed需要使用gnu sed
- [ ] 增加外网支持
- [x] 自动检测环境,Mac使用ipconfig,Linux使用ip
2016/3/23
- 进一步POSIX化,支持Mac和大部分Linux发行版
- 更改配置文件格式
# Credit
+56 -7
View File
@@ -46,7 +46,54 @@ case $(uname) in
esac
# Get script dir
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# See: http://stackoverflow.com/a/29835459/4449544
rreadlink() ( # Execute the function in a *subshell* to localize variables and the effect of `cd`.
target=$1 fname= targetDir= CDPATH=
# Try to make the execution environment as predictable as possible:
# All commands below are invoked via `command`, so we must make sure that `command`
# itself is not redefined as an alias or shell function.
# (Note that command is too inconsistent across shells, so we don't use it.)
# `command` is a *builtin* in bash, dash, ksh, zsh, and some platforms do not even have
# an external utility version of it (e.g, Ubuntu).
# `command` bypasses aliases and shell functions and also finds builtins
# in bash, dash, and ksh. In zsh, option POSIX_BUILTINS must be turned on for that
# to happen.
{ \unalias command; \unset -f command; } >/dev/null 2>&1
[ -n "$ZSH_VERSION" ] && options[POSIX_BUILTINS]=on # make zsh find *builtins* with `command` too.
while :; do # Resolve potential symlinks until the ultimate target is found.
[ -L "$target" ] || [ -e "$target" ] || { command printf '%s\n' "ERROR: '$target' does not exist." >&2; return 1; }
command cd "$(command dirname -- "$target")" # Change to target dir; necessary for correct resolution of target path.
fname=$(command basename -- "$target") # Extract filename.
[ "$fname" = '/' ] && fname='' # !! curiously, `basename /` returns '/'
if [ -L "$fname" ]; then
# Extract [next] target path, which may be defined
# *relative* to the symlink's own directory.
# Note: We parse `ls -l` output to find the symlink target
# which is the only POSIX-compliant, albeit somewhat fragile, way.
target=$(command ls -l "$fname")
target=${target#* -> }
continue # Resolve [next] symlink target.
fi
break # Ultimate target reached.
done
targetDir=$(command pwd -P) # Get canonical dir. path
# Output the ultimate target's canonical path.
# Note that we manually resolve paths ending in /. and /.. to make sure we have a normalized path.
if [ "$fname" = '.' ]; then
command printf '%s\n' "${targetDir%/}"
elif [ "$fname" = '..' ]; then
# Caveat: something like /var/.. will resolve to /private (assuming /var@ -> /private/var), i.e. the '..' is applied
# AFTER canonicalization.
command printf '%s\n' "$(command dirname -- "${targetDir}")"
else
command printf '%s\n' "${targetDir%/}/$fname"
fi
)
DIR=$(dirname -- "$(rreadlink "$0")")
# Global Variables:
@@ -58,7 +105,7 @@ arPass=""
# Load config
source $DIR/dns.conf
#. $DIR/dns.conf
# Get Domain IP
# arg: domain
@@ -124,8 +171,10 @@ arDdnsCheck() {
}
# DDNS
echo ${#domains[@]}
for index in ${!domains[@]}; do
echo "${domains[index]} ${subdomains[index]}"
arDdnsCheck "${domains[index]}" "${subdomains[index]}"
done
#echo ${#domains[@]}
#for index in ${!domains[@]}; do
# echo "${domains[index]} ${subdomains[index]}"
# arDdnsCheck "${domains[index]}" "${subdomains[index]}"
#done
. $DIR/dns.conf
+9 -4
View File
@@ -1,5 +1,10 @@
arMail="test@gmail.com"
arPass="test"
# For security reasons, it is recommended that you use token-based auth instead
# arMail="test@gmail.com"
# arPass="123"
declare -a domains=("test.net")
declare -a subdomains=("abc")
# Combine your token ID and token together as follows
arToken="12345,7676f344eaeaea9074c123451234512d"
# Place each domain you want to check as follows
# you can have multiple arDdnsCheck blocks
arDdnsCheck "test.org" "subdomain"