|
|
@@ -11,20 +11,20 @@ local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
|
|
|
# converts text to ascii then passes to curl. allowing special characters to be sent e.g %
|
|
|
# http://stackoverflow.com/a/10660730
|
|
|
fn_rawurlencode() {
|
|
|
- local string="${1}"
|
|
|
- local strlen=${#string}
|
|
|
- local encoded=""
|
|
|
- local pos c o
|
|
|
+ local string="${1}"
|
|
|
+ local strlen=${#string}
|
|
|
+ local encoded=""
|
|
|
+ local pos c o
|
|
|
|
|
|
- for (( pos=0 ; pos<strlen ; pos++ )); do
|
|
|
- c=${string:$pos:1}
|
|
|
- case "$c" in
|
|
|
- [-_.~a-zA-Z0-9] ) o="${c}" ;;
|
|
|
- * ) printf -v o '%%%02x' "'$c"
|
|
|
- esac
|
|
|
- encoded+="${o}"
|
|
|
- done
|
|
|
- echo "${encoded}"
|
|
|
+ for (( pos=0 ; pos<strlen ; pos++ )); do
|
|
|
+ c=${string:$pos:1}
|
|
|
+ case "$c" in
|
|
|
+ [-_.~a-zA-Z0-9] ) o="${c}" ;;
|
|
|
+ * ) printf -v o '%%%02x' "'$c"
|
|
|
+ esac
|
|
|
+ encoded+="${o}"
|
|
|
+ done
|
|
|
+ echo "${encoded}"
|
|
|
}
|
|
|
|
|
|
pbalertbody=$(fn_rawurlencode "Message: ${alertbody} - More Info: ${alerturl}")
|
|
|
@@ -37,9 +37,9 @@ pushbulletsend=$(curl --silent -u """${pushbullettoken}"":" -d channel_tag="${ch
|
|
|
pberror=$(echo "${pushbulletsend}" |grep "error_code")
|
|
|
pberrormsg=$(echo "${pushbulletsend}" |sed -n -e 's/^.*error_code//p' | tr -d '=\";,:{}')
|
|
|
if [ -n "${pberror}" ]; then
|
|
|
- fn_print_fail_nl "Sending Pushbullet alert: ${pberrormsg}"
|
|
|
- fn_script_log_fatal "Sending Pushbullet alert: ${pberrormsg}"
|
|
|
+ fn_print_fail_nl "Sending Pushbullet alert: ${pberrormsg}"
|
|
|
+ fn_script_log_fatal "Sending Pushbullet alert: ${pberrormsg}"
|
|
|
else
|
|
|
- fn_print_ok_nl "Sending Pushbullet alert"
|
|
|
- fn_script_log_pass "Sent Pushbullet alert"
|
|
|
+ fn_print_ok_nl "Sending Pushbullet alert"
|
|
|
+ fn_script_log_pass "Sent Pushbullet alert"
|
|
|
fi
|