Commit 19c43451 authored by neil's avatar neil
Browse files

fix shfmt

parent d5d38b33
...@@ -144,7 +144,7 @@ _netlify_rest() { ...@@ -144,7 +144,7 @@ _netlify_rest() {
export _H1="Content-Type: application/json" export _H1="Content-Type: application/json"
export _H2="Authorization: Bearer $token_trimmed" export _H2="Authorization: Bearer $token_trimmed"
:>"$HTTP_HEADER" : >"$HTTP_HEADER"
if [ "$m" != "GET" ]; then if [ "$m" != "GET" ]; then
_debug data "$data" _debug data "$data"
......
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
# Created: 2019-02-17 # Created: 2019-02-17
# Fixed by: @der-berni # Fixed by: @der-berni
# Modified: 2020-04-07 # Modified: 2020-04-07
# #
# Use ONECOM_KeepCnameProxy to keep the CNAME DNS record # Use ONECOM_KeepCnameProxy to keep the CNAME DNS record
# export ONECOM_KeepCnameProxy="1" # export ONECOM_KeepCnameProxy="1"
# #
# export ONECOM_User="username" # export ONECOM_User="username"
# export ONECOM_Password="password" # export ONECOM_Password="password"
# #
......
...@@ -41,40 +41,40 @@ _ovh_get_api() { ...@@ -41,40 +41,40 @@ _ovh_get_api() {
case "${_ogaep}" in case "${_ogaep}" in
ovh-eu | ovheu) ovh-eu | ovheu)
printf "%s" $OVH_EU printf "%s" $OVH_EU
return return
;; ;;
ovh-ca | ovhca) ovh-ca | ovhca)
printf "%s" $OVH_CA printf "%s" $OVH_CA
return return
;; ;;
kimsufi-eu | kimsufieu) kimsufi-eu | kimsufieu)
printf "%s" $KSF_EU printf "%s" $KSF_EU
return return
;; ;;
kimsufi-ca | kimsufica) kimsufi-ca | kimsufica)
printf "%s" $KSF_CA printf "%s" $KSF_CA
return return
;; ;;
soyoustart-eu | soyoustarteu) soyoustart-eu | soyoustarteu)
printf "%s" $SYS_EU printf "%s" $SYS_EU
return return
;; ;;
soyoustart-ca | soyoustartca) soyoustart-ca | soyoustartca)
printf "%s" $SYS_CA printf "%s" $SYS_CA
return return
;; ;;
runabove-ca | runaboveca) runabove-ca | runaboveca)
printf "%s" $RAV_CA printf "%s" $RAV_CA
return return
;; ;;
*) *)
_err "Unknown parameter : $1" _err "Unknown parameter : $1"
return 1 return 1
;; ;;
esac esac
} }
......
...@@ -136,11 +136,12 @@ dns_pleskxml_rm() { ...@@ -136,11 +136,12 @@ dns_pleskxml_rm() {
# Reduce output to one line per DNS record, filtered for TXT records with a record ID only (which they should all have) # Reduce output to one line per DNS record, filtered for TXT records with a record ID only (which they should all have)
# Also strip out spaces between tags, redundant <data> and </data> group tags and any <self-closing/> tags # Also strip out spaces between tags, redundant <data> and </data> group tags and any <self-closing/> tags
reclist="$(_api_response_split "$pleskxml_prettyprint_result" 'result' '<status>ok</status>' \ reclist="$(
| sed 's# \{1,\}<\([a-zA-Z]\)#<\1#g;s#</\{0,1\}data>##g;s#<[a-z][^/<>]*/>##g' \ _api_response_split "$pleskxml_prettyprint_result" 'result' '<status>ok</status>' |
| grep "<site-id>${root_domain_id}</site-id>" \ sed 's# \{1,\}<\([a-zA-Z]\)#<\1#g;s#</\{0,1\}data>##g;s#<[a-z][^/<>]*/>##g' |
| grep '<id>[0-9]\{1,\}</id>' \ grep "<site-id>${root_domain_id}</site-id>" |
| grep '<type>TXT</type>' grep '<id>[0-9]\{1,\}</id>' |
grep '<type>TXT</type>'
)" )"
if [ -z "$reclist" ]; then if [ -z "$reclist" ]; then
...@@ -151,10 +152,11 @@ dns_pleskxml_rm() { ...@@ -151,10 +152,11 @@ dns_pleskxml_rm() {
_debug "Got list of DNS TXT records for root domain '$root_domain_name':" _debug "Got list of DNS TXT records for root domain '$root_domain_name':"
_debug "$reclist" _debug "$reclist"
recid="$(_value "$reclist" \ recid="$(
| grep "<host>${fulldomain}.</host>" \ _value "$reclist" |
| grep "<value>${txtvalue}</value>" \ grep "<host>${fulldomain}.</host>" |
| sed 's/^.*<id>\([0-9]\{1,\}\)<\/id>.*$/\1/' grep "<value>${txtvalue}</value>" |
sed 's/^.*<id>\([0-9]\{1,\}\)<\/id>.*$/\1/'
)" )"
if ! _value "$recid" | grep '^[0-9]\{1,\}$' >/dev/null; then if ! _value "$recid" | grep '^[0-9]\{1,\}$' >/dev/null; then
...@@ -220,11 +222,11 @@ _countdots() { ...@@ -220,11 +222,11 @@ _countdots() {
# Last line could change to <sed -n '/.../p'> instead, with suitable escaping of ['"/$], # Last line could change to <sed -n '/.../p'> instead, with suitable escaping of ['"/$],
# if future Plesk XML API changes ever require extended regex # if future Plesk XML API changes ever require extended regex
_api_response_split() { _api_response_split() {
printf '%s' "$1" \ printf '%s' "$1" |
| sed 's/^ +//;s/ +$//' \ sed 's/^ +//;s/ +$//' |
| tr -d '\n\r' \ tr -d '\n\r' |
| sed "s/<\/\{0,1\}$2>/${NEWLINE}/g" \ sed "s/<\/\{0,1\}$2>/${NEWLINE}/g" |
| grep "$3" grep "$3"
} }
#################### Private functions below (DNS functions) ################################## #################### Private functions below (DNS functions) ##################################
...@@ -261,14 +263,15 @@ _call_api() { ...@@ -261,14 +263,15 @@ _call_api() {
elif [ "$statuslines_count_okay" -ne "$statuslines_count_total" ]; then elif [ "$statuslines_count_okay" -ne "$statuslines_count_total" ]; then
# We have some status lines that aren't "ok". Any available details are in API response fields "status" "errcode" and "errtext" # We have some status lines that aren't "ok". Any available details are in API response fields "status" "errcode" and "errtext"
# Workaround for basic regex: # Workaround for basic regex:
# - filter output to keep only lines like this: "SPACES<TAG>text</TAG>SPACES" (shouldn't be necessary with prettyprint but guarantees subsequent code is ok) # - filter output to keep only lines like this: "SPACES<TAG>text</TAG>SPACES" (shouldn't be necessary with prettyprint but guarantees subsequent code is ok)
# - then edit the 3 "useful" error tokens individually and remove closing tags on all lines # - then edit the 3 "useful" error tokens individually and remove closing tags on all lines
# - then filter again to remove all lines not edited (which will be the lines not starting A-Z) # - then filter again to remove all lines not edited (which will be the lines not starting A-Z)
errtext="$(_value "$pleskxml_prettyprint_result" \ errtext="$(
| grep '^ *<[a-z]\{1,\}>[^<]*<\/[a-z]\{1,\}> *$' \ _value "$pleskxml_prettyprint_result" |
| sed 's/^ *<status>/Status: /;s/^ *<errcode>/Error code: /;s/^ *<errtext>/Error text: /;s/<\/.*$//' \ grep '^ *<[a-z]\{1,\}>[^<]*<\/[a-z]\{1,\}> *$' |
| grep '^[A-Z]' sed 's/^ *<status>/Status: /;s/^ *<errcode>/Error code: /;s/^ *<errtext>/Error text: /;s/<\/.*$//' |
grep '^[A-Z]'
)" )"
fi fi
......
...@@ -87,11 +87,11 @@ _get_root() { ...@@ -87,11 +87,11 @@ _get_root() {
for ITEM in ${domains_list}; do for ITEM in ${domains_list}; do
case "${domain}" in case "${domain}" in
*${ITEM}*) *${ITEM}*)
_domain=${ITEM} _domain=${ITEM}
_debug _domain "${_domain}" _debug _domain "${_domain}"
return 0 return 0
;; ;;
esac esac
done done
......
...@@ -98,24 +98,24 @@ _mail_cmnd() { ...@@ -98,24 +98,24 @@ _mail_cmnd() {
_MAIL_ARGS="" _MAIL_ARGS=""
case $(basename "$_MAIL_BIN") in case $(basename "$_MAIL_BIN") in
sendmail) sendmail)
if [ -n "$MAIL_FROM" ]; then if [ -n "$MAIL_FROM" ]; then
_MAIL_ARGS="-f '$MAIL_FROM'" _MAIL_ARGS="-f '$MAIL_FROM'"
fi fi
;; ;;
mutt | mail) mutt | mail)
_MAIL_ARGS="-s '$_subject'" _MAIL_ARGS="-s '$_subject'"
;; ;;
msmtp) msmtp)
if [ -n "$MAIL_FROM" ]; then if [ -n "$MAIL_FROM" ]; then
_MAIL_ARGS="-f '$MAIL_FROM'" _MAIL_ARGS="-f '$MAIL_FROM'"
fi fi
if [ -n "$MAIL_MSMTP_ACCOUNT" ]; then if [ -n "$MAIL_MSMTP_ACCOUNT" ]; then
_MAIL_ARGS="$_MAIL_ARGS -a '$MAIL_MSMTP_ACCOUNT'" _MAIL_ARGS="$_MAIL_ARGS -a '$MAIL_MSMTP_ACCOUNT'"
fi fi
;; ;;
*) ;; *) ;;
esac esac
echo "'$_MAIL_BIN' $_MAIL_ARGS '$MAIL_TO'" echo "'$_MAIL_BIN' $_MAIL_ARGS '$MAIL_TO'"
...@@ -123,16 +123,16 @@ _mail_cmnd() { ...@@ -123,16 +123,16 @@ _mail_cmnd() {
_mail_body() { _mail_body() {
case $(basename "$_MAIL_BIN") in case $(basename "$_MAIL_BIN") in
sendmail | ssmtp | msmtp) sendmail | ssmtp | msmtp)
if [ -n "$MAIL_FROM" ]; then if [ -n "$MAIL_FROM" ]; then
echo "From: $MAIL_FROM" echo "From: $MAIL_FROM"
fi fi
echo "To: $MAIL_TO" echo "To: $MAIL_TO"
echo "Subject: $subject" echo "Subject: $subject"
echo "Content-Type: $contenttype" echo "Content-Type: $contenttype"
echo echo
;; ;;
esac esac
echo "$_content" echo "$_content"
......
...@@ -52,15 +52,15 @@ teams_send() { ...@@ -52,15 +52,15 @@ teams_send() {
_content=$(echo "$_content" | _json_encode) _content=$(echo "$_content" | _json_encode)
case "$_statusCode" in case "$_statusCode" in
0) 0)
_color="${TEAMS_SUCCESS_COLOR:-$_color_success}" _color="${TEAMS_SUCCESS_COLOR:-$_color_success}"
;; ;;
1) 1)
_color="${TEAMS_ERROR_COLOR:-$_color_danger}" _color="${TEAMS_ERROR_COLOR:-$_color_danger}"
;; ;;
2) 2)
_color="${TEAMS_SKIP_COLOR:-$_color_muted}" _color="${TEAMS_SKIP_COLOR:-$_color_muted}"
;; ;;
esac esac
_color=$(echo "$_color" | tr -cd 'a-fA-F0-9') _color=$(echo "$_color" | tr -cd 'a-fA-F0-9')
......
...@@ -71,13 +71,13 @@ _xmpp_bin() { ...@@ -71,13 +71,13 @@ _xmpp_bin() {
_xmpp_cmnd() { _xmpp_cmnd() {
case $(basename "$_XMPP_BIN") in case $(basename "$_XMPP_BIN") in
sendxmpp) sendxmpp)
echo "'$_XMPP_BIN' '$XMPP_TO' $XMPP_BIN_ARGS" echo "'$_XMPP_BIN' '$XMPP_TO' $XMPP_BIN_ARGS"
;; ;;
*) *)
_err "Command $XMPP_BIN is not supported, use sendxmpp." _err "Command $XMPP_BIN is not supported, use sendxmpp."
return 1 return 1
;; ;;
esac esac
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment