Improve and prevent password characters break curl sent data

Set head notice
This commit is contained in:
Luis Guzmán 2020-07-04 14:57:37 -05:00
parent 0ce43a7e50
commit c6db500940
1 changed files with 15 additions and 3 deletions

View File

@ -23,6 +23,18 @@ if [ "$MODE" = "debug" ]; then
set -x set -x
fi fi
if ! [ $(id -u) = 0 ]; then
echo "You need to be root or have sudo privileges!"
exit 0
fi
clear
echo '
########################################################################
Grafana Dashboard addon
########################################################################
by Software, IT & Networks Ltd
'
run_service() { run_service() {
systemclt enable $1 systemclt enable $1
systemctl restart $1 systemctl restart $1
@ -33,7 +45,7 @@ TEL_JIT="/etc/telegraf/telegraf.d/jitsi.conf"
GRAFANA_INI="/etc/grafana/grafana.ini" GRAFANA_INI="/etc/grafana/grafana.ini"
DOMAIN=$(ls /etc/prosody/conf.d/ | grep -v localhost | awk -F'.cfg' '{print $1}' | awk '!NF || !seen[$0]++') DOMAIN=$(ls /etc/prosody/conf.d/ | grep -v localhost | awk -F'.cfg' '{print $1}' | awk '!NF || !seen[$0]++')
WS_CONF="/etc/nginx/sites-enabled/$DOMAIN.conf" WS_CONF="/etc/nginx/sites-enabled/$DOMAIN.conf"
GRAFANA_PASS="$(tr -dc "a-zA-Z0-9#_*" < /dev/urandom | fold -w 14 | head -n1)" GRAFANA_PASS="$(tr -dc "a-zA-Z0-9#_*=" < /dev/urandom | fold -w 14 | head -n1)"
# Min requirements # Min requirements
apt update && apt install -y gnupg2 curl wget jq apt update && apt install -y gnupg2 curl wget jq
@ -158,7 +170,7 @@ curl -X PUT -H "Content-Type: application/json;charset=UTF-8" -d \
echo " echo "
# Create InfluxDB datasource # Create InfluxDB datasource
" "
curl -X \ curl -s -k -u "admin:$GRAFANA_PASS" -X \
POST -H 'Content-Type: application/json;charset=UTF-8' -d \ POST -H 'Content-Type: application/json;charset=UTF-8' -d \
'{ '{
"name": "InfluxDB", "name": "InfluxDB",
@ -167,7 +179,7 @@ POST -H 'Content-Type: application/json;charset=UTF-8' -d \
"access": "proxy", "access": "proxy",
"isDefault": true, "isDefault": true,
"database": "jitsi" "database": "jitsi"
}' http://admin:$GRAFANA_PASS@localhost:3000/api/datasources; echo "" }' http://localhost:3000/api/datasources; echo ""
echo " echo "
# Add Grafana Dashboard # Add Grafana Dashboard