net: init-metrics.sh - urlencode influx password (#5594)

* net: init-metrics.sh - urlencode influx password

* old backticks bad!

* Move urlencode() to common.sh

* Make urlencode() vars local

Co-Authored-By: Michael Vines <mvines@gmail.com>
This commit is contained in:
Trent Nelson 2019-08-21 19:06:09 -06:00 committed by GitHub
parent faafee6b42
commit 5034331131
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -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
}

View File

@ -60,6 +60,8 @@ else
[[ -n $password ]] || { echo "Password not specified"; exit 1; }
echo
password="$(urlencode "$password")"
query() {
echo "$*"
curl -XPOST \