@ -12,11 +12,6 @@ slacksitename="" # Title of site "Example Site
slackchannel = "" # Slack Channel #example
slackchannel = "" # Slack Channel #example
slackuri = "" # URI for Slack WebHook "https://hooks.slack.com/services/xxxxx"
slackuri = "" # URI for Slack WebHook "https://hooks.slack.com/services/xxxxx"
#tolerant_is_set=0
top_exit_code = -1;
#argument_total=$#
#tolerant_is_set=false;
debug_output_echo ( ) {
debug_output_echo ( ) {
if [ ! -z $debug_mode_active ] ; then
if [ ! -z $debug_mode_active ] ; then
if [ $debug_mode_active -eq 1 ] ; then
if [ $debug_mode_active -eq 1 ] ; then
@ -24,7 +19,11 @@ debug_output_echo () {
fi
fi
fi
fi
}
}
exit_code ( ) {
exit_code ( ) {
if [ -z $top_exit_code ] ; then
top_exit_code = -999
fi
if [ $top_exit_code -lt $excode ] ; then
if [ $top_exit_code -lt $excode ] ; then
top_exit_code = $excode
top_exit_code = $excode
fi
fi
@ -179,19 +178,29 @@ cf_ddns() {
fi
fi
fi
fi
}
}
cf_parameter_commands ( ) {
cf_parameter_commands ( ) {
case " $parameter_current " in
case ${ parameter_current : 1 } in
"- debug" )
"debug" )
debug_mode_active = 1
debug_mode_active = 1
; ;
; ;
"- help" )
" help" )
echo "# crontab\n"
echo "# crontab\n"
echo "*/5 * * * * /bin/bash /home/user/cloudflare-ddns-updater/cloudflare-init.sh"
echo "*/5 * * * * /bin/bash /home/user/cloudflare-ddns-updater/cloudflare-init.sh"
echo '*/5 * * * * /bin/bash /home/user/cloudflare-ddns-updater/cloudflare-init.sh mydomain.com example.com www.example.com x1.example.com'
echo '*/5 * * * * /bin/bash /home/user/cloudflare-ddns-updater/cloudflare-init.sh mydomain.com example.com www.example.com x1.example.com'
echo -e "\nAdd in -tolerant option that get continue if when reason to exit, this should be first parameter\n"
echo -e $output_help
echo -e $output_help
; ;
; ;
"tolerant" )
tolerant_is_set = 1
logger_output = "DDNS Updater: Been set as being tolerant"
debug_output += $logger_output "\n"
logger $logger_output
; ;
*)
*)
echo "Unknown ***************************"
logger_output = " DDNS Updater: invalid parameter option been defined [ ${ parameter_current } ] "
debug_output += $logger_output "\n"
logger -s $logger_output
; ;
; ;
esac
esac
}
}
@ -202,35 +211,30 @@ cf_err_human () {
if [ ${# auth_email } -eq 0 ] ; then
if [ ${# auth_email } -eq 0 ] ; then
err_is_human = 1
err_is_human = 1
logger_output = "DDNS Updater: ERROR [auth_email] record not been defined"
logger_output = "DDNS Updater: ERROR [auth_email] record not been defined"
debug_output += $logger_output "\n"
logger -s $logger_output
logger -s $logger_output
fi
fi
if [ $auth_method != "token" ] && [ $auth_method != "global" ] ; then
if [ $auth_method != "token" ] && [ $auth_method != "global" ] ; then
err_is_human = 1
err_is_human = 1
logger_output = 'DDNS Updater: ERROR [auth_method] is invaled it has to be defined "token" "global" defined'
logger_output = 'DDNS Updater: ERROR [auth_method] is invaled it has to be defined "token" "global" defined'
debug_output += $logger_output "\n"
logger -s $logger_output
logger -s $logger_output
fi
fi
if [ ${# auth_key } -eq 0 ] ; then
if [ ${# auth_key } -eq 0 ] ; then
err_is_human = 1
err_is_human = 1
logger_output = "DDNS Updater: ERROR [auth_key] record not been defined"
logger_output = "DDNS Updater: ERROR [auth_key] record not been defined"
debug_output += $logger_output "\n"
logger -s $logger_output
logger -s $logger_output
fi
fi
if [ ${# zone_identifier } -eq 0 ] ; then
if [ ${# zone_identifier } -eq 0 ] ; then
err_is_human = 1
err_is_human = 1
logger_output = "DDNS Updater: ERROR [zone_identifier] record has not been defined"
logger_output = "DDNS Updater: ERROR [zone_identifier] record has not been defined"
debug_output += $logger_output "\n"
logger -s $logger_output
logger -s $logger_output
fi
fi
if [ ${# record_name } -eq 0 ] && [ $argument_total -eq 0 ] ; then
if [ ${# record_name } -eq 0 ] && [ $argument_total -eq 0 ] ; then
err_is_human = 1
err_is_human = 1
logger_output = "DDNS Updater: ERROR [record_name] record not has been defined"
logger_output = "DDNS Updater: ERROR [record_name] record not has been defined"
debug_output += $logger_output "\n"
logger -s $logger_output
logger -s $logger_output
fi
fi
@ -242,25 +246,20 @@ cf_err_human () {
if [ $tolerant_is_set -lt 0 ] || [ $tolerant_is_set -gt 1 ] ; then
if [ $tolerant_is_set -lt 0 ] || [ $tolerant_is_set -gt 1 ] ; then
err_is_human = 1
err_is_human = 1
logger_output = "DDNS Updater: ERROR [tolerant_is_set] can only by 0 or 1"
logger_output = "DDNS Updater: ERROR [tolerant_is_set] can only by 0 or 1"
debug_output += $logger_output "\n"
logger -s $logger_output
logger -s $logger_output
fi
fi
if [ $err_is_human -eq 1 ] ; then
if [ $err_is_human -eq 1 ] ; then
#It is done this way so all errors get disclosed
#It is done if there is error detected above
debug_output_echo
exit 1
exit 1
fi
fi
}
}
argument_total = $#
argument_total = $#
tolerant_is_set = 1
#top_exit_code=-999
debug_output = ""
debug_output = ""
cf_err_human
cf_err_human
if [ $# -ne 0 ] ; then
if [ $# -ne 0 ] ; then
# If a parameter has been defined in will ignore any setting in [record_name]
# If a parameter has been defined in will ignore any setting in [record_name]
parameter = ( " $@ " )
parameter = ( " $@ " )
@ -278,5 +277,6 @@ else
# If no parameter been used it will use one above [record_name]
# If no parameter been used it will use one above [record_name]
cf_ddns
cf_ddns
fi
fi
debug_output_echo
debug_output_echo
exit $err_is_human
exit $err_is_human