diff --git a/LICENSE b/LICENSE
index 2def0e8..6fae7d0 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,5 +1,5 @@
GNU AFFERO GENERAL PUBLIC LICENSE
- Version 3, 19 November 2007
+ Version 3, 19 November 2007 !
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
diff --git a/hooks/post_user_delete b/hooks/post_user_delete
index 5a2af87..5ac3e13 100644
--- a/hooks/post_user_delete
+++ b/hooks/post_user_delete
@@ -2,7 +2,7 @@
source /usr/share/yunohost/helpers
user=$1
-app="zabbix"
+app="ynhzabbix"
db_name=$(ynh_app_setting_get $app db_name)
db_user=$(ynh_app_setting_get $app db_user)
diff --git a/scripts/install b/scripts/install
index af1def0..ee24abe 100644
--- a/scripts/install
+++ b/scripts/install
@@ -165,6 +165,11 @@ do
fi
done
+#disable default admin
+lastid=$(mysql -u$db_user -p$db_pwd $db_name -BN -e "SELECT max(id) from \`users_groups\`")
+lastid=$(($lastid + 1 ))
+mysql -u$db_user -p$db_pwd $db_name -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 1);"
+
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
diff --git a/scripts/upgrade b/scripts/upgrade
index 84f1e3f..e3c7182 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -22,6 +22,9 @@ is_public=$(ynh_app_setting_get $app is_public)
final_path=$(ynh_app_setting_get $app final_path)
language=$(ynh_app_setting_get $app language)
db_name=$(ynh_app_setting_get $app db_name)
+db_user=$(ynh_app_setting_get $app db_user)
+db_pwd=$(ynh_app_setting_get $app mysqlpwd)
+
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
@@ -48,6 +51,21 @@ if [ -z $final_path ]; then
ynh_app_setting_set $app final_path $final_path
fi
+#=================================================
+# Disable default admin for security issue
+#=================================================
+haveDefaultAdminDisabled=$(mysql -BN -u$db_user -p$db_pwd $db_name -BN -e "SELECT count(id) from \`users_groups\` where userid=1 and usrgrpid=9")
+
+if [ "$haveDefaultAdminDisabled" -eq 0 ] ;then
+ echo "Disable default admin"
+ #disable default admin
+ lastid=$(mysql -u$db_user -p$db_pwd $db_name -BN -e "SELECT max(id) from \`users_groups\`")
+ lastid=$(($lastid + 1 ))
+ mysql -u$db_user -p$db_pwd $db_name -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 1);"
+else
+ echo "default admin already disabled"
+fi
+
#=================================================
# CHECK THE PATH
#=================================================
diff --git a/sources/extra_files/app/Template_Yunohost.xml b/sources/extra_files/app/Template_Yunohost.xml
new file mode 100644
index 0000000..f7121a0
--- /dev/null
+++ b/sources/extra_files/app/Template_Yunohost.xml
@@ -0,0 +1,1402 @@
+
+
+ 4.0
+ 2019-01-15T12:48:48Z
+
+
+ Templates/Applications
+
+
+
+
+ Template Yunohost
+ Template Yunohost
+ cat /etc/sudoers.d/zabbix
+zabbix ALL=(root) NOPASSWD: /etc/zabbix/zabbix_agentd.d/yunohost.sh
+
+cat /etc/zabbix/zabbix_agentd.d/userP_yunohost.conf
+UserParameter=yunohost.users.discover,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.users.discover
+UserParameter=yunohost.user.quota[*],sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.user.quota "$1"
+UserParameter=yunohost.domains.discover,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.domains.discover
+UserParameter=yunohost.domain.cert[*],sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.domain.cert "$1"
+UserParameter=yunohost.services.discover,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.services.discover
+UserParameter=yunohost.service.status[*],sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.service.status "$1"
+UserParameter=yunohost.backups.number,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.backups.number
+UserParameter=yunohost.backups.ageoflastbackup,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.backups.ageoflastbackup
+UserParameter=yunohost.ports.tcp.discovery,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.ports.tcp.discovery
+UserParameter=yunohost.ports.udp.discovery,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.ports.udp.discovery
+UserParameter=yunohost.migrations.lastinstalled,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.migrations.lastinstalled
+UserParameter=yunohost.migrations.lastavailable,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.migrations.lastavailable
+
+cat /etc/zabbix/zabbix_agentd.d/yunohost.sh
+#!/bin/bash
+yunobin=$(which yunohost)
+
+
+if [ "$1" == "yunohost.users.discover" ];then
+ users=$($yunobin user list --fields 'uid' | awk -F ': ' '/username: / {print $2}');echo -n "{\"data\":[";for user in $users;do echo -n "{\"{#USERNAME}\":\"$user\"},";done | sed 's/,$//' ;echo "]}"
+fi
+
+if [ "$1" == "yunohost.user.quota" ] ;then
+ quota=$($yunobin user info "$2" | grep -Po "use:.*\(\K([0-9]{1,3})");if [ -z "$quota" ];then echo 0 ; else echo "$quota" ;fi
+fi
+
+if [ "$1" == "yunohost.domains.discover" ] ;then
+ domains=$($yunobin domain list --plain);echo -n "{\"data\":[";for domain in $domains;do echo -n "{\"{#DOMAIN}\":\"$domain\"},";done | sed 's/,$//' ;echo "]}"
+fi
+
+if [ "$1" == "yunohost.domain.cert" ] ;then
+ $yunobin domain cert-status "$2" --plain | awk '/#/{ next;} {printf "%s;",$0} END {print ""}'
+fi
+
+if [ "$1" == "yunohost.services.discover" ] ;then
+ services=$($yunobin service status | grep -Po '^([A-Za-z]+)(?=(:))');echo -n "{\"data\":[";for service in $services;do echo -n "{\"{#SERVICE}\":\"$service\"},";done | sed 's/,$//' ;echo "]}"
+fi
+
+if [ "$1" == "yunohost.service.status" ] ;then
+ $yunobin service status "$2" --plain | awk '/#/{ next;} {printf "%s;",$0} END {print ""}'
+fi
+
+if [ "$1" == "yunohost.backups.number" ] ;then
+ $yunobin backup list --plain | wc -l
+fi
+
+if [ "$1" == "yunohost.backups.ageoflastbackup" ] ;then
+ timestamp=$(date +"%d/%m/%Y %H:%M" -d"$($yunobin backup list -i | tail -n 4 | head -n 1 | grep -Po 'created_at: \K(.*)')")
+ echo $(( ($(date +%s) - $(date -d"$timestamp" +%s))/(60*60*24) ))
+fi
+
+
+if [ "$1" == "yunohost.ports.tcp.discovery" ] ;then
+ ports=$($yunobin firewall list -r --plain | awk '/#ipv4/{flag=1;next}/#uPnP/{flag=0}flag' | awk '/##TCP/{flag=1;next}/##TCP/{flag=0}flag');echo -n "{\"data\":[";for port in $ports;do echo -n "{\"{#PORT}\":\"$port\"},";done | sed 's/,$//' ;echo "]}"
+fi
+
+if [ "$1" == "yunohost.ports.udp.discovery" ] ;then
+ ports=$($yunobin firewall list -r --plain | awk '/#ipv4/{flag=1;next}/#uPnP/{flag=0}flag' | awk '/##UDP/{flag=1;next}/##TCP/{flag=0}flag');echo -n "{\"data\":[";for port in $ports;do echo -n "{\"{#PORT}\":\"$port\"},";done | sed 's/,$//' ;echo "]}"
+fi
+
+if [ "$1" == "yunohost.migrations.lastinstalled" ] ;then
+ $yunobin tools migrations state | grep -Po " number: \K(.*)"
+fi
+
+if [ "$1" == "yunohost.migrations.lastavailable" ] ;then
+ $yunobin tools migrations list | tail -n 1 | grep -Po " number: \K(.*)"
+fi
+
+
+ Templates/Applications
+
+
+
+
+ Yunohost : Backups
+
+
+ Yunohost : Certificates
+
+
+ Yunohost : Certificates : Expiration
+
+
+ Yunohost : Certificates : State
+
+
+ Yunohost : Migrations
+
+
+ Yunohost : Ports
+
+
+ Yunohost : Services
+
+
+ Yunohost : Services : Status
+
+
+ Yunohost : Users
+
+
+
+ -
+ Age of the last backup
+ 0
+
+
+ yunohost.backups.ageoflastbackup
+ 1d
+ 90d
+ 365d
+ 0
+ 3
+
+ days
+
+
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Yunohost : Backups
+
+
+
+
+
+
+ 3s
+
+
+
+ 200
+ 1
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+
+ -
+ Number of Yunohost backups
+ 0
+
+
+ yunohost.backups.number
+ 1d
+ 90d
+ 365d
+ 0
+ 3
+
+
+
+
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Yunohost : Backups
+
+
+
+
+
+
+ 3s
+
+
+
+ 200
+ 1
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+
+ -
+ Id of the last migration available
+ 0
+
+
+ yunohost.migrations.lastavailable
+ 1d
+ 90d
+ 365d
+ 0
+ 3
+
+
+
+
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Yunohost : Migrations
+
+
+
+
+
+
+ 3s
+
+
+
+ 200
+ 1
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+
+ -
+ Id of the last migration installed
+ 0
+
+
+ yunohost.migrations.lastinstalled
+ 1d
+ 90d
+ 365d
+ 0
+ 3
+
+
+
+
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Yunohost : Migrations
+
+
+
+
+
+
+ 3s
+
+
+
+ 200
+ 1
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+
+
+
+
+ Yunohost domains
+ 0
+
+
+ yunohost.domains.discover
+ 1d
+ 0
+
+
+
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+
+
+
+
+
+
+ 0
+
+
+
+ 30d
+
+
+
+ Certificate {#DOMAIN} expiration
+ 18
+
+
+ yunohost.domain.cert.expiration[{#DOMAIN}]
+ 0
+ 180d
+ 365d
+ 0
+ 3
+
+ d
+
+
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Yunohost : Certificates
+
+
+ Yunohost : Certificates : Expiration
+
+
+
+
+
+
+ 5
+ (.*);(.*);(.*);(.*);(.*);(.*);(.*);(.*);
+\2
+
+
+
+ 3s
+
+
+
+ 200
+ 1
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+
+ yunohost.domain.cert[{#DOMAIN}]
+
+
+
+ Certificate {#DOMAIN} state
+ 18
+
+
+ yunohost.domain.cert.state[{#DOMAIN}]
+ 0
+ 180d
+ 0
+ 0
+ 1
+
+
+
+
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Yunohost : Certificates
+
+
+ Yunohost : Certificates : State
+
+
+
+ Yunohost : certificates
+
+
+
+
+ 5
+ (.*);(.*);(.*);(.*);(.*);(.*);(.*);(.*);
+\3:unknown=0:critical=1:warning=2:attention=3:good=4;great=5
+
+
+ 5
+ ^(unknown|critical|warning|attention|good|great):(?=.*\1=(\d))
+\2
+
+
+
+ 3s
+
+
+
+ 200
+ 1
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+
+ yunohost.domain.cert[{#DOMAIN}]
+
+
+
+ Informations {#DOMAIN} full
+ 0
+
+
+ yunohost.domain.cert[{#DOMAIN}]
+ 1d
+ 180d
+ 0
+ 0
+ 1
+
+
+
+
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Yunohost : Certificates
+
+
+
+
+
+
+ 3s
+
+
+
+ 200
+ 1
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+
+ 3s
+
+
+
+ 200
+ 1
+ 0
+
+
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+
+ TCP Ports opened
+ 0
+
+
+ yunohost.ports.tcp.discover
+ 1d
+ 0
+
+
+
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+
+
+
+
+
+
+ 0
+
+
+
+ 7d
+
+
+
+ Check TCP port {#PORT} responding
+ 0
+
+
+ net.tcp.service[tcp,127.0.0.1,{#PORT}]
+ 900s
+ 90d
+ 365d
+ 0
+ 3
+
+
+
+
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Yunohost : Ports
+
+
+
+ Service state
+
+
+
+
+ 3s
+
+
+
+ 200
+ 1
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ {Template Yunohost:net.tcp.service[tcp,127.0.0.1,{#PORT}].last()}=0
+ 0
+
+ TCP port {#PORT} not responding
+ 0
+
+
+ 0
+ 4
+
+ 0
+ 1
+
+
+
+
+
+
+
+ 3s
+
+
+
+ 200
+ 1
+ 0
+
+
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+
+ UDP Ports opened
+ 0
+
+
+ yunohost.ports.udp.discover
+ 1d
+ 0
+
+
+
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+
+
+
+
+
+
+ 0
+
+
+
+ 0d
+
+
+
+ Check UDP port {#PORT} listening
+ 0
+
+
+ net.udp.listen[{#PORT}]
+ 900s
+ 90d
+ 365d
+ 0
+ 3
+
+
+
+
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Yunohost : Ports
+
+
+
+ Service state
+
+
+
+
+ 3s
+
+
+
+ 200
+ 1
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ {Template Yunohost:net.udp.listen[{#PORT}].last()}=0
+ 0
+
+ UDP port {#PORT} not listening
+ 0
+
+
+ 0
+ 4
+
+ 0
+ 1
+
+
+
+
+
+
+
+ 3s
+
+
+
+ 200
+ 1
+ 0
+
+
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+
+ Yunohost services
+ 0
+
+
+ yunohost.services.discover
+ 1d
+ 0
+
+
+
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+
+
+
+
+
+
+ 0
+
+
+
+ 7d
+
+
+
+ Yunohost service {#SERVICE} status
+ 18
+
+
+ yunohost.service.statusrunp[{#SERVICE}]
+ 0
+ 7d
+ 365d
+ 0
+ 3
+
+
+
+
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Yunohost : Services
+
+
+ Yunohost : Services : Status
+
+
+
+ Yunohost : services
+
+
+
+
+ 5
+ (.*);(.*);(.*);(.*);(.*);(.*);(.*);
+\6:inactive=0:active=1:unknown=2;disabled=3
+
+
+ 5
+ ^(inactive|active|unknown|disabled):(?=.*\1=(\d))
+\2
+
+
+
+ 3s
+
+
+
+ 200
+ 1
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+
+ yunohost.service.status[{#SERVICE}]
+
+
+
+ Yunohost service {#SERVICE} status (full)
+ 0
+
+
+ yunohost.service.status[{#SERVICE}]
+ 15m
+ 7d
+ 0
+ 0
+ 1
+
+
+
+
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Yunohost : Services
+
+
+
+
+
+
+ 3s
+
+
+
+ 200
+ 1
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ {Template Yunohost:yunohost.service.statusrunp[{#SERVICE}].last()}=3
+ 0
+
+ Service {#SERVICE} disabled
+ 0
+
+
+ 0
+ 4
+
+ 0
+ 1
+
+
+
+
+ {Template Yunohost:yunohost.service.statusrunp[{#SERVICE}].last()}=0
+ 0
+
+ Service {#SERVICE} state is inactive
+ 0
+
+
+ 0
+ 4
+
+ 0
+ 1
+
+
+
+
+ {Template Yunohost:yunohost.service.statusrunp[{#SERVICE}].last()}=2
+ 0
+
+ Service {#SERVICE} state is unknown
+ 0
+
+
+ 0
+ 4
+
+ 0
+ 1
+
+
+
+
+
+
+
+ 3s
+
+
+
+ 200
+ 1
+ 0
+
+
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+
+ Yunohost users
+ 0
+
+
+ yunohost.users.discover
+ 1d
+ 0
+
+
+
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+
+
+
+
+
+
+ 0
+
+
+
+ 30d
+
+
+
+ Quota percent for user {#USERNAME}
+ 0
+
+
+ yunohost.user.quota[{#USERNAME}]
+ 1h
+ 30d
+ 365d
+ 0
+ 3
+
+ %
+
+
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+
+
+
+
+
+
+ 0
+
+
+ Yunohost : Users
+
+
+
+
+
+
+ 3s
+
+
+
+ 200
+ 1
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ {Template Yunohost:yunohost.user.quota[{#USERNAME}].last()}>=80
+ 0
+
+ User {#USERNAME} quota exceed 80%
+ 0
+
+
+ 0
+ 3
+
+ 0
+ 1
+
+
+
+
+ {Template Yunohost:yunohost.user.quota[{#USERNAME}].last()}>=90
+ 0
+
+ User {#USERNAME} quota exceed 90%
+ 0
+
+
+ 0
+ 4
+
+ 0
+ 1
+
+
+
+
+
+
+
+ 3s
+
+
+
+ 200
+ 1
+ 0
+
+
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+
+
+
+ {Template Yunohost:yunohost.migrations.lastavailable.last()}<>{Template Yunohost:yunohost.migrations.lastinstalled.last()}
+ 0
+
+ Yunhost has migration in pending state
+ 0
+
+
+ 0
+ 1
+
+ 0
+ 1
+
+
+
+
+ {Template Yunohost:yunohost.backups.ageoflastbackup.last()}>=7
+ 0
+
+ Yunhost hasn't backup since 7 days
+ 0
+
+
+ 0
+ 4
+
+ 0
+ 1
+
+
+
+
+ {Template Yunohost:yunohost.backups.number.last()}=0
+ 0
+
+ Yunhost hasn't backup yet
+ 0
+
+
+ 0
+ 4
+
+ 0
+ 1
+
+
+
+
+
+
+ Service state
+
+
+ 0
+ Down
+
+
+ 1
+ Up
+
+
+
+
+ Yunohost : certificates
+
+
+ 0
+ unknown
+
+
+ 1
+ critical
+
+
+ 2
+ warning
+
+
+ 3
+ attention
+
+
+ 4
+ good
+
+
+ 5
+ great
+
+
+
+
+ Yunohost : services
+
+
+ 0
+ inactive
+
+
+ 1
+ active
+
+
+ 2
+ unknow
+
+
+ 3
+ disabled
+
+
+
+
+