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:
parent
b0f7705bcc
commit
4a11730a00
4 changed files with 22 additions and 3 deletions
|
@ -1,7 +1,9 @@
|
||||||
Grafana for YunoHost
|
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.
|
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:
|
# 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
|
* if the NetData package is installed, configures NetData to feed InfluxDB every minute
|
||||||
* installs Grafana as dashboard server
|
* installs Grafana as dashboard server
|
||||||
* creates a Grafana Data Source to fetch data from InfluxDB (and hence NetData!)
|
* creates a Grafana Data Source to fetch data from InfluxDB (and hence NetData!)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
; Manifest
|
; Manifest
|
||||||
domain="domain.tld" (DOMAIN)
|
domain="domain.tld" (DOMAIN)
|
||||||
path="/path" (PATH)
|
path="/path" (PATH)
|
||||||
|
admin="john" (USER)
|
||||||
is_public=1 (PUBLIC|public=1|private=0)
|
is_public=1 (PUBLIC|public=1|private=0)
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
|
|
|
@ -42,6 +42,15 @@
|
||||||
"example": "/grafana",
|
"example": "/grafana",
|
||||||
"default": "/grafana"
|
"default": "/grafana"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "admin",
|
||||||
|
"type": "user",
|
||||||
|
"ask": {
|
||||||
|
"en": "Choose an admin user",
|
||||||
|
"fr": "Choisissez l'administrateur"
|
||||||
|
},
|
||||||
|
"example": "homer"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "is_public",
|
"name": "is_public",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|
|
@ -13,6 +13,7 @@ source ./_common.sh
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path=$YNH_APP_ARG_PATH
|
path=$YNH_APP_ARG_PATH
|
||||||
|
admin=$YNH_APP_ARG_ADMIN
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
# Source YunoHost helpers
|
# Source YunoHost helpers
|
||||||
|
@ -26,6 +27,7 @@ sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||||
|| ynh_die "Path not available: ${domain}${path}"
|
|| ynh_die "Path not available: ${domain}${path}"
|
||||||
|
|
||||||
# Save app settings
|
# Save app settings
|
||||||
|
ynh_app_setting_set "$app" admin "$admin"
|
||||||
ynh_app_setting_set "$app" is_public "$is_public"
|
ynh_app_setting_set "$app" is_public "$is_public"
|
||||||
|
|
||||||
# Install needed dependency for HTTPS apt access
|
# Install needed dependency for HTTPS apt access
|
||||||
|
@ -144,10 +146,15 @@ while [ -z "$(sudo netstat -lnput|grep grafana)" ] ; do
|
||||||
sleep 5s
|
sleep 5s
|
||||||
done
|
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
|
# Import default dashboard for NetData
|
||||||
hostname=$(hostname)
|
hostname=$(hostname)
|
||||||
sed -i "s@yunohost.yunohost.org@$hostname@g" ../conf/grafana_init_data.sql
|
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
|
# Restart grafana server to take db change into account
|
||||||
sudo systemctl restart grafana-server
|
sudo systemctl restart grafana-server
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue