add debug mode

This commit is contained in:
Luis Guzmán 2020-07-04 08:55:29 -05:00
parent a748bc8b75
commit 457f75ecb1
1 changed files with 17 additions and 0 deletions

View File

@ -9,6 +9,20 @@
# SwITNet Ltd © - 2020, https://switnet.net/ # SwITNet Ltd © - 2020, https://switnet.net/
# GPLv3 or later. # GPLv3 or later.
while getopts m: option
do
case "${option}"
in
m) MODE=${OPTARG};;
\?) echo "Usage: sudo ./grafana.sh [-m debug]" && exit;;
esac
done
#DEBUG
if [ "$MODE" = "debug" ]; then
set -x
fi
MAIN_TEL="/etc/telegraf/telegraf.conf" MAIN_TEL="/etc/telegraf/telegraf.conf"
TEL_JIT="/etc/telegraf/telegraf.d/jitsi.conf" TEL_JIT="/etc/telegraf/telegraf.d/jitsi.conf"
GRAFANA_INI="/etc/grafana/grafana.ini" GRAFANA_INI="/etc/grafana/grafana.ini"
@ -138,6 +152,7 @@ curl -X PUT -H "Content-Type: application/json" -d "{
\"newPassword\": \"$GRAFANA_PASS\", \"newPassword\": \"$GRAFANA_PASS\",
\"confirmNew\": \"$GRAFANA_PASS\" \"confirmNew\": \"$GRAFANA_PASS\"
}" http://admin:admin@localhost:3000/api/user/password }" http://admin:admin@localhost:3000/api/user/password
read -n 1 -s -r -p "Press any key to continue..."$'\n'
echo " echo "
# Create InfluxDB datasource # Create InfluxDB datasource
@ -152,6 +167,7 @@ POST -H 'Content-Type: application/json;charset=UTF-8' -d \
"isDefault":true, "isDefault":true,
"database":"jitsi" "database":"jitsi"
}' http://admin:$GRAFANA_PASS@localhost:3000/api/datasources }' http://admin:$GRAFANA_PASS@localhost:3000/api/datasources
read -n 1 -s -r -p "Press any key to continue..."$'\n'
echo " echo "
# Add Grafana Dashboard # Add Grafana Dashboard
@ -170,6 +186,7 @@ for d in "${ds[@]}"; do
\"pluginId\":\"influxdb\",\"value\":\"$grafana_datasource\"}]}" \ \"pluginId\":\"influxdb\",\"value\":\"$grafana_datasource\"}]}" \
$grafana_host/api/dashboards/import; echo "" $grafana_host/api/dashboards/import; echo ""
done done
read -n 1 -s -r -p "Press any key to continue..."$'\n'
echo " echo "
Go check: Go check: