dynamicdns: Fix passing password via stdin

* Add an option to pass the password via cmdline (optional, not used by
  plinth) if called manually.

* Fix: If -p option was not the last given option, everything after -p
  was lost.  Closes #310.
This commit is contained in:
Daniel Steglich 2015-11-28 13:37:48 +00:00 committed by Sunil Mohan Adapa
parent 2197da54aa
commit a90039889d
No known key found for this signature in database
GPG Key ID: 36C361440C9BC971

View File

@ -65,7 +65,7 @@ doGetOpt()
basicauth=0
ignoreCertError=0
while getopts ":s:d:u:p:I:U:c:b:" opt; do
while getopts ":s:d:u:P:I:U:c:b:p" opt; do
case ${opt} in
s)
if [ "${OPTARG}" != "${EMPTYSTRING}" ];then
@ -80,6 +80,9 @@ doGetOpt()
u)
user=${OPTARG}
;;
P)
pass=${OPTARG}
;;
p)
if read -t 0; then
IFS= read -r pass
@ -293,7 +296,7 @@ doGetWANIP()
doUpdate()
{
local dnsentry=$(nslookup "${host}"|tail -n2|grep A|sed s/[^0-9.]//g)
if [ "${dnsentry}" = "${wanip}" ];then
if [ "${dnsentry}" = "${wanip}" ];then
return
fi
if [ ! -z "${server}" ];then
@ -428,6 +431,7 @@ case ${cmd} in
echo "-s <server> Gnudip Server address"
echo "-d <domain> Domain to be updated"
echo "-u <user> Account username"
echo "-P <password> Account password"
echo "-p Read Account Password from stdin"
echo "-I <IP check URL> A URL which returns the IP of the client who is requesting"
echo "-U <update URL> The update URL (a HTTP GET on this URL will be done)"