1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/grafana_ynh.git synced 2024-09-03 20:36:29 +02:00

Ask for admin user during installation (fixes #1)

This commit is contained in:
Jimmy Monin 2017-03-05 14:41:56 +01:00
parent b0f7705bcc
commit 4a11730a00
4 changed files with 22 additions and 3 deletions

View file

@ -1,7 +1,9 @@
Grafana for YunoHost
-----------------------------
**Important: This package is designed to be fed by the NetData application for monitoring measures, so please make sure the YunoHost NetData package is installed before installing it!**
**Important: This package is designed to be fed by the NetData application for monitoring measures, so please make sure the YunoHost [NetData package](https://github.com/YunoHost-Apps/netdata_ynh/) is installed before installing it!**
NetData only collects, displays and sets alarms based on data from the last hour; this packages allows to archive every metrics and put up statistics and dashboards on the long term.
Note: You can use it without NetData, but you'll have to install a collection application (e.g. collectd) to gather data.
@ -18,7 +20,7 @@ Note: You can use it without NetData, but you'll have to install a collection ap
---
# Package description:
* installs InfluxDB as timeseries database
* installs InfluxDB as time series database
* if the NetData package is installed, configures NetData to feed InfluxDB every minute
* installs Grafana as dashboard server
* creates a Grafana Data Source to fetch data from InfluxDB (and hence NetData!)

View file

@ -3,6 +3,7 @@
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
admin="john" (USER)
is_public=1 (PUBLIC|public=1|private=0)
; Checks
pkg_linter=1

View file

@ -42,6 +42,15 @@
"example": "/grafana",
"default": "/grafana"
},
{
"name": "admin",
"type": "user",
"ask": {
"en": "Choose an admin user",
"fr": "Choisissez l'administrateur"
},
"example": "homer"
},
{
"name": "is_public",
"type": "boolean",

View file

@ -13,6 +13,7 @@ source ./_common.sh
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
# Source YunoHost helpers
@ -26,6 +27,7 @@ sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|| ynh_die "Path not available: ${domain}${path}"
# Save app settings
ynh_app_setting_set "$app" admin "$admin"
ynh_app_setting_set "$app" is_public "$is_public"
# Install needed dependency for HTTPS apt access
@ -144,10 +146,15 @@ while [ -z "$(sudo netstat -lnput|grep grafana)" ] ; do
sleep 5s
done
# Change admin name to the specified one
mail=$(ynh_user_get_info "$admin" 'mail')
ynh_mysql_connect_as $dbuser $dbpass $dbname <<< "UPDATE user SET login=\"$admin\", email=\"$mail\" WHERE login=\"admin\";"
# Import default dashboard for NetData
hostname=$(hostname)
sed -i "s@yunohost.yunohost.org@$hostname@g" ../conf/grafana_init_data.sql
mysql -u $dbuser -p$dbpass $dbname < ../conf/grafana_init_data.sql
ynh_mysql_connect_as $dbuser $dbpass $dbname < ../conf/grafana_init_data.sql
# Restart grafana server to take db change into account
sudo systemctl restart grafana-server