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 authored and Sunil Mohan Adapa committed 2016-02-01 10:46:48 +05:30
1 parent 2197da54aa
commit a90039889d
1 file changed
+6 -2
+6 -2
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)"