diff --git a/net/common.sh b/net/common.sh index a55ec89427..73d6257085 100644 --- a/net/common.sh +++ b/net/common.sh @@ -76,3 +76,21 @@ loadConfigFile() { buildSshOptions configureMetrics } + +# https://gist.github.com/cdown/1163649 +urlencode() { + declare s="$1" + declare l=$((${#s} - 1)) + for i in $(seq 0 $l); do + declare c="${s:$i:1}" + case $c in + [a-zA-Z0-9.~_-]) + echo -n "$c" + ;; + *) + printf '%%%02X' "'$c" + ;; + esac + done +} + diff --git a/net/init-metrics.sh b/net/init-metrics.sh index ae29ffba68..d68e9d7659 100755 --- a/net/init-metrics.sh +++ b/net/init-metrics.sh @@ -60,6 +60,8 @@ else [[ -n $password ]] || { echo "Password not specified"; exit 1; } echo + password="$(urlencode "$password")" + query() { echo "$*" curl -XPOST \