mirror of
https://github.com/YunoHost-Apps/zabbix_ynh.git
synced 2024-09-03 20:36:14 +02:00
second example_ynh
This commit is contained in:
parent
a81f0be175
commit
119dfc3369
4 changed files with 37 additions and 49 deletions
|
@ -5,7 +5,7 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# dependencies used by the app
|
# dependencies used by the app
|
||||||
pkg_dependencies="libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php7.3 php7.3-bcmath ttf-dejavu-core php7.3-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd libjs-prototype jq zabbix-server-mysql zabbix-agent zabbix-frontend-php"
|
pkg_dependencies="libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php$YNH_DEFAULT_PHP_VERSION php$YNH_DEFAULT_PHP_VERSION-bcmath ttf-dejavu-core php$YNH_DEFAULT_PHP_VERSION-bcmath patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base libsnmp30 snmptrapd snmpd libjs-prototype jq zabbix-server-mysql zabbix-agent zabbix-frontend-php"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
|
@ -61,6 +61,7 @@ enable_admin_user(){
|
||||||
|
|
||||||
import_template(){
|
import_template(){
|
||||||
ynh_print_info --message="Import yunohost template"
|
ynh_print_info --message="Import yunohost template"
|
||||||
|
|
||||||
zabbixFullpath=https://$domain$path_url
|
zabbixFullpath=https://$domain$path_url
|
||||||
localpath=$(find /var/cache/yunohost/ -name "Template_Yunohost.xml")
|
localpath=$(find /var/cache/yunohost/ -name "Template_Yunohost.xml")
|
||||||
sudoUserPpath=$(find /var/cache/yunohost/ -name "etc_sudoers.d_zabbix")
|
sudoUserPpath=$(find /var/cache/yunohost/ -name "etc_sudoers.d_zabbix")
|
||||||
|
|
|
@ -47,6 +47,7 @@ ynh_script_progression --message="Storing installation settings..."
|
||||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||||
|
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
||||||
ynh_app_setting_set --app=$app --key=language --value=$language
|
ynh_app_setting_set --app=$app --key=language --value=$language
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -58,20 +59,20 @@ ynh_script_progression --message="Installing dependencies..."
|
||||||
|
|
||||||
pid=$(pgrep -f '/usr/bin/python3 /usr/bin/unattended-upgrade --download-only' || true)
|
pid=$(pgrep -f '/usr/bin/python3 /usr/bin/unattended-upgrade --download-only' || true)
|
||||||
if [ ! -z "$pid" ] ;then
|
if [ ! -z "$pid" ] ;then
|
||||||
ynh_script_progression --message="Check and wait end of unattended-upgrade of package_check" -w 1
|
ynh_script_progression --message="Check and wait end of unattended-upgrade of package_check"
|
||||||
tail --pid=$pid -f /dev/null
|
tail --pid=$pid -f /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_script_progression --message="Remove Zabbix if already installed" -w 1
|
ynh_script_progression --message="Remove Zabbix if already installed"
|
||||||
apt-get purge zabbix* -y
|
apt-get purge zabbix* -y
|
||||||
if compgen -G "/var/cache/apt/archives/zabbix-server-mysql*" > /dev/null; then
|
if compgen -G "/var/cache/apt/archives/zabbix-server-mysql*" > /dev/null; then
|
||||||
ynh_secure_remove /var/cache/apt/archives/zabbix-server-mysql*
|
ynh_secure_remove /var/cache/apt/archives/zabbix-server-mysql*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_script_progression --message="Install Zabbix repository" -w 3
|
ynh_script_progression --message="Install Zabbix repository"
|
||||||
install_zabbix_repo
|
install_zabbix_repo
|
||||||
|
|
||||||
ynh_script_progression --message="Update and install dependencies" -w 5
|
ynh_script_progression --message="Update and install dependencies"
|
||||||
#ynh_package_update no need cause ynh_install_app_dependencies after
|
#ynh_package_update no need cause ynh_install_app_dependencies after
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
dpkg -i --force-confmiss /var/cache/apt/archives/zabbix-server-mysql*
|
dpkg -i --force-confmiss /var/cache/apt/archives/zabbix-server-mysql*
|
||||||
|
@ -97,7 +98,7 @@ ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
||||||
export mysqlconn="mysql -u$db_user -p$db_pwd $db_name"
|
export mysqlconn="mysql -u$db_user -p$db_pwd $db_name"
|
||||||
mysql --user=$db_user --password=$db_pwd --database=zabbix -e "ALTER DATABASE $db_name CHARACTER SET utf8 COLLATE utf8_general_ci;"
|
mysql --user=$db_user --password=$db_pwd --database=zabbix -e "ALTER DATABASE $db_name CHARACTER SET utf8 COLLATE utf8_general_ci;"
|
||||||
|
|
||||||
ynh_script_progression --message="Import default data in database..." -w 25
|
ynh_script_progression --message="Import default data in database..."
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | $mysqlconn
|
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | $mysqlconn
|
||||||
|
|
||||||
|
@ -157,23 +158,10 @@ ynh_script_progression --message="Configuring PHP-FPM..."
|
||||||
|
|
||||||
# Create a dedicated PHP-FPM config
|
# Create a dedicated PHP-FPM config
|
||||||
ynh_add_fpm_config
|
ynh_add_fpm_config
|
||||||
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
#=================================================
|
|
||||||
# ...
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP APPLICATION WITH CURL
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Reload SSOwat config
|
|
||||||
yunohost app ssowatconf
|
|
||||||
|
|
||||||
# Reload Nginx
|
|
||||||
systemctl reload nginx
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD A CONFIGURATION
|
# ADD A CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -202,26 +190,26 @@ systemctl enable zabbix-server --quiet && systemctl restart zabbix-server
|
||||||
update_initZabbixConf
|
update_initZabbixConf
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX AND PHP-FPM
|
# SETUP APPLICATION WITH CURL
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Setuping application with CURL..."
|
||||||
|
|
||||||
systemctl reload nginx
|
# Set the app as temporarily public for curl call
|
||||||
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
|
ynh_script_progression --message="Configuring SSOwat..."
|
||||||
|
# Making the app public for curl
|
||||||
# Reload SSOwat config
|
ynh_permission_update --permission="main" --add="visitors"
|
||||||
yunohost app ssowatconf
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# Import Yunohost template
|
# Import Yunohost template
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Importing last template Yunohost in Zabbix" -w 5
|
ynh_script_progression --message="Importing last template Yunohost in Zabbix"
|
||||||
|
|
||||||
import_template
|
import_template
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# Link Yunohost template to the ZAbbix Server Host
|
# Link Yunohost template to the ZAbbix Server Host
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Importing last template Yunohost in Zabbix" -w 5
|
ynh_script_progression --message="Importing last template Yunohost in Zabbix"
|
||||||
|
|
||||||
link_template
|
link_template
|
||||||
|
|
||||||
|
@ -231,6 +219,9 @@ link_template
|
||||||
|
|
||||||
disable_admin_user
|
disable_admin_user
|
||||||
|
|
||||||
|
# Remove the public access
|
||||||
|
ynh_permission_update --permission="main" --remove="visitors"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -247,11 +238,6 @@ yunohost service add zabbix-agent --description="Management Zabbix agent daemon
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
|
|
||||||
|
|
||||||
# Reload SSOwat config
|
|
||||||
yunohost app ssowatconf
|
|
||||||
|
|
||||||
#test if zabbix server is started
|
#test if zabbix server is started
|
||||||
check_proc_zabbixagent
|
check_proc_zabbixagent
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,22 @@ ynh_script_progression --message="Removing the MySQL database..."
|
||||||
# Remove a database if it exists, along with the associated user
|
# Remove a database if it exists, along with the associated user
|
||||||
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing NGINX web server configuration..."
|
||||||
|
|
||||||
|
# Remove the dedicated NGINX config
|
||||||
|
ynh_remove_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE PHP-FPM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing PHP-FPM configuration..."
|
||||||
|
|
||||||
|
# Remove the dedicated PHP-FPM config
|
||||||
|
ynh_remove_fpm_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEPENDENCIES
|
# REMOVE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -65,22 +81,6 @@ do
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get purge --allow-change-held-packages "$zabbix_pkg" -y
|
DEBIAN_FRONTEND=noninteractive apt-get purge --allow-change-held-packages "$zabbix_pkg" -y
|
||||||
done
|
done
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing NGINX web server configuration..."
|
|
||||||
|
|
||||||
# Remove the dedicated NGINX config
|
|
||||||
ynh_remove_nginx_config
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE PHP-FPM CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing PHP-FPM configuration..."
|
|
||||||
|
|
||||||
# Remove the dedicated PHP-FPM config
|
|
||||||
ynh_remove_fpm_config
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC REMOVE
|
# SPECIFIC REMOVE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -29,6 +29,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
nonfree=$(ynh_app_setting_get --app=$app --key=nonfree)
|
nonfree=$(ynh_app_setting_get --app=$app --key=nonfree)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue