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:
parent
faafee6b42
commit
5034331131
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,8 @@ else
|
|||
[[ -n $password ]] || { echo "Password not specified"; exit 1; }
|
||||
echo
|
||||
|
||||
password="$(urlencode "$password")"
|
||||
|
||||
query() {
|
||||
echo "$*"
|
||||
curl -XPOST \
|
||||
|
|
Loading…
Reference in New Issue