fixed indention

This commit is contained in:
Daniel Steglich 2015-03-04 10:28:28 +00:00
parent ad1d94f6a6
commit 1075665a90

View File

@ -34,7 +34,7 @@ doGetOpt()
{ {
basicauth=0 basicauth=0
ignoreCertError=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:" opt; do
case ${opt} in case ${opt} in
s) s)
@ -157,73 +157,73 @@ doReplaceVars()
{ {
local url=`echo ${updateurl} | sed "s/<Ip>/${wanip}/g"` local url=`echo ${updateurl} | sed "s/<Ip>/${wanip}/g"`
url=`echo ${url} | sed "s/<Domain>/${host}/g"` url=`echo ${url} | sed "s/<Domain>/${host}/g"`
url=`echo ${url} | sed "s/<User>/${user}/g"` url=`echo ${url} | sed "s/<User>/${user}/g"`
url=`echo ${url} | sed "s/<Pass>/${pass}/g"` url=`echo ${url} | sed "s/<Pass>/${pass}/g"`
url=`echo ${url} | sed "s/'//g"` url=`echo ${url} | sed "s/'//g"`
updateurl=$url updateurl=$url
} }
doStatus() doStatus()
{ {
PROC=$(pgrep ${TOOLNAME}) PROC=$(pgrep ${TOOLNAME})
if [ -f ${CRONJOB} ];then if [ -f ${CRONJOB} ];then
echo $ENABLED_STRING echo $ENABLED_STRING
elif [ ! -z ${PROC} ];then elif [ ! -z ${PROC} ];then
echo $ENABLED_STRING echo $ENABLED_STRING
else else
echo $DISABLED_STRING echo $DISABLED_STRING
fi fi
if [ ! -z ${server} ];then if [ ! -z ${server} ];then
echo ${server} echo ${server}
else else
echo $DISABLED_STRING echo $DISABLED_STRING
fi fi
if [ ! -z ${host} ];then if [ ! -z ${host} ];then
echo ${host} echo ${host}
else else
echo $DISABLED_STRING echo $DISABLED_STRING
fi fi
if [ ! -z ${user} ];then if [ ! -z ${user} ];then
echo ${user} echo ${user}
else else
echo $DISABLED_STRING echo $DISABLED_STRING
fi fi
if [ ! -z ${pass} ];then if [ ! -z ${pass} ];then
echo ${pass} echo ${pass}
else else
echo $DISABLED_STRING echo $DISABLED_STRING
fi fi
if [ ! -z ${ipurl} ];then if [ ! -z ${ipurl} ];then
echo ${ipurl} echo ${ipurl}
else else
echo $DISABLED_STRING echo $DISABLED_STRING
fi fi
if [ ! -z ${updateurl} ];then if [ ! -z ${updateurl} ];then
local url=`echo ${updateurl} | sed "s/'//g"` local url=`echo ${updateurl} | sed "s/'//g"`
echo ${url} echo ${url}
else else
echo $DISABLED_STRING echo $DISABLED_STRING
fi fi
if [ ! -z ${basicauth} ];then if [ ! -z ${basicauth} ];then
echo ${basicauth} echo ${basicauth}
else else
echo $DISABLED_STRING echo $DISABLED_STRING
fi fi
if [ ! -z ${ignoreCertError} ];then if [ ! -z ${ignoreCertError} ];then
echo ${ignoreCertError} echo ${ignoreCertError}
else else
echo $DISABLED_STRING echo $DISABLED_STRING
fi fi
} }
doGetWANIP() doGetWANIP()
{ {
if [ ! -z ${ipurl} ];then if [ ! -z ${ipurl} ];then
outfile=$(mktemp) outfile=$(mktemp)
${WGET} ${WGETOPTIONS} -O ${outfile} ${ipurl} ${WGET} ${WGETOPTIONS} -O ${outfile} ${ipurl}
wanip=$(cat ${outfile}) wanip=$(cat ${outfile})
rm ${outfile} rm ${outfile}
[ -z ${wanip} ] && wanip=${NOIP} [ -z ${wanip} ] && wanip=${NOIP}
else else
#no WAN IP found because of missing check URL #no WAN IP found because of missing check URL
wanip=${NOIP} wanip=${NOIP}
@ -232,28 +232,28 @@ doGetWANIP()
doUpdate() doUpdate()
{ {
if [ ! -z ${server} ];then if [ ! -z ${server} ];then
start-stop-daemon -S -x ${UPDATE_TOOL} -m -p ${PIDFILE} -- -c ${cfgfile} start-stop-daemon -S -x ${UPDATE_TOOL} -m -p ${PIDFILE} -- -c ${cfgfile}
fi fi
if [ ! -z ${updateurl} ];then
doReplaceVars
if [ "${basicauth}" = "enabled" ];then if [ ! -z ${updateurl} ];then
local wgetoptions=" --user $user --password $pass " doReplaceVars
fi
if [ "${ignoreCertError}" = "enabled" ];then
local wgetoptions=" --no-check-certificate "
fi
$WGET ${wgetoptions} "${updateurl}" if [ "${basicauth}" = "enabled" ];then
#ToDo: check the returning text from WEB Server. User need to give expected string. local wgetoptions=" --user $user --password $pass "
if [ $? -eq 0 ];then fi
${0} success $wanip if [ "${ignoreCertError}" = "enabled" ];then
else local wgetoptions=" --no-check-certificate "
${0} failed fi
fi
fi $WGET ${wgetoptions} "${updateurl}"
#ToDo: check the returning text from WEB Server. User need to give expected string.
if [ $? -eq 0 ];then
${0} success $wanip
else
${0} failed
fi
fi
} }
cmd=${1} cmd=${1}
@ -267,21 +267,21 @@ case ${cmd} in
doWriteCFG doWriteCFG
;; ;;
start) start)
doGetWANIP doGetWANIP
if [ "$(cat $HELPERCFG |grep ^NAT | awk '{print $2}')" = "no" ];then if [ "$(cat $HELPERCFG |grep ^NAT | awk '{print $2}')" = "no" ];then
#if we are not behind a NAT device and we use gnudip, start the daemon tool #if we are not behind a NAT device and we use gnudip, start the daemon tool
if [ -f ${CFG} -a ! -z $(cat ${cfgfile} 2> /dev/null |grep server |cut -d = -f 2 |grep -v ^\'\')];then if [ -f ${CFG} -a ! -z $(cat ${cfgfile} 2> /dev/null |grep server |cut -d = -f 2 |grep -v ^\'\')];then
mv ${CFG_disabled} ${CFG} mv ${CFG_disabled} ${CFG}
/etc/init.d/${TOOLNAME} start /etc/init.d/${TOOLNAME} start
fi fi
#if we are not behind a NAT device and we use update-URL, add a cronjob #if we are not behind a NAT device and we use update-URL, add a cronjob
#(daemon tool does not support update-URL feature) #(daemon tool does not support update-URL feature)
if [ ! -z $(cat $HELPERCFG |grep ^POSTURL | awk '{print $2}') ];then if [ ! -z $(cat $HELPERCFG |grep ^POSTURL | awk '{print $2}') ];then
echo "*/${UPDATEMINUTES} * * * * root $0 update" > ${CRONJOB} echo "*/${UPDATEMINUTES} * * * * root $0 update" > ${CRONJOB}
$0 update $0 update
fi fi
else else
#if we are behind a NAT device, add a cronjob (daemon tool cannot monitor WAN IP changes) #if we are behind a NAT device, add a cronjob (daemon tool cannot monitor WAN IP changes)
echo "*/${UPDATEMINUTES} * * * * root $0 update" > $CRONJOB echo "*/${UPDATEMINUTES} * * * * root $0 update" > $CRONJOB
$0 update $0 update
fi fi
@ -327,11 +327,11 @@ case ${cmd} in
cat /proc/uptime |awk '{print $1}' |cut -d . -f 1 > ${LASTUPDATE} cat /proc/uptime |awk '{print $1}' |cut -d . -f 1 > ${LASTUPDATE}
#if called from cronjob, the current IP is given as parameter #if called from cronjob, the current IP is given as parameter
if [ $# -eq 1 ];then if [ $# -eq 1 ];then
echo ${1} > ${IPFILE} echo ${1} > ${IPFILE}
else else
#if called from ez-ipupdate daemon, no WAN IP is given as parameter #if called from ez-ipupdate daemon, no WAN IP is given as parameter
doGetWANIP doGetWANIP
echo ${wanip} > ${IPFILE} echo ${wanip} > ${IPFILE}
fi fi
;; ;;
failed) failed)
@ -347,10 +347,10 @@ case ${cmd} in
;; ;;
status) status)
doReadCFG doReadCFG
doStatus doStatus
;; ;;
get-timer) get-timer)
echo ${UPDATEMINUTES} echo ${UPDATEMINUTES}
;; ;;
clean) clean)
rm ${CFGDIR}/* rm ${CFGDIR}/*