|
@@ -1,7 +1,5 @@
|
|
|
#!/bin/bash
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
-#=================================================
|
|
|
|
|
-# GENERIC START
|
|
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# IMPORT GENERIC HELPERS
|
|
# IMPORT GENERIC HELPERS
|
|
|
#=================================================
|
|
#=================================================
|
|
@@ -9,105 +7,14 @@
|
|
|
source _common.sh
|
|
source _common.sh
|
|
|
source /usr/share/yunohost/helpers
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
-#=================================================
|
|
|
|
|
-# MANAGE SCRIPT FAILURE
|
|
|
|
|
-#=================================================
|
|
|
|
|
-
|
|
|
|
|
-ynh_clean_setup () {
|
|
|
|
|
- ynh_clean_check_starting
|
|
|
|
|
-}
|
|
|
|
|
-# Exit if an error occurs during the execution of the script
|
|
|
|
|
-ynh_abort_if_errors
|
|
|
|
|
-
|
|
|
|
|
-#=================================================
|
|
|
|
|
-# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
|
-#=================================================
|
|
|
|
|
-
|
|
|
|
|
-domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
|
-path_url=$YNH_APP_ARG_PATH
|
|
|
|
|
-is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
|
|
|
-language=$YNH_APP_ARG_LANGUAGE
|
|
|
|
|
-admin=$YNH_APP_ARG_ADMIN
|
|
|
|
|
-
|
|
|
|
|
-app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
-
|
|
|
|
|
-#=================================================
|
|
|
|
|
-# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
|
|
|
-#=================================================
|
|
|
|
|
-ynh_script_progression --message="Validating installation parameters..."
|
|
|
|
|
-
|
|
|
|
|
-remove_previous_zabbix
|
|
|
|
|
-
|
|
|
|
|
-final_path=/var/www/$app
|
|
|
|
|
-test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
|
|
|
|
-
|
|
|
|
|
-# Register (book) web path
|
|
|
|
|
-ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
|
|
|
|
-
|
|
|
|
|
-#=================================================
|
|
|
|
|
-# STORE SETTINGS FROM MANIFEST
|
|
|
|
|
-#=================================================
|
|
|
|
|
-ynh_script_progression --message="Storing installation settings..."
|
|
|
|
|
-
|
|
|
|
|
-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=language --value=$language
|
|
|
|
|
-ynh_app_setting_set --app=$app --key=admin --value=$admin
|
|
|
|
|
-
|
|
|
|
|
-#=================================================
|
|
|
|
|
-# STANDARD MODIFICATIONS
|
|
|
|
|
-#=================================================
|
|
|
|
|
-# INSTALL DEPENDENCIES
|
|
|
|
|
-#=================================================
|
|
|
|
|
-ynh_script_progression --message="Installing dependencies..."
|
|
|
|
|
-
|
|
|
|
|
-ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
|
|
|
|
-ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="http://repo.zabbix.com/zabbix/5.0/debian $(lsb_release -sc) main" --package="$zabbix_pkg_dependencies" --key="https://repo.zabbix.com/zabbix-official-repo.key"
|
|
|
|
|
-
|
|
|
|
|
-ynh_replace_string --match_string="# $language.UTF-8 UTF-8" --replace_string="$language.UTF-8 UTF-8" --target_file=/etc/locale.gen
|
|
|
|
|
-locale-gen
|
|
|
|
|
-
|
|
|
|
|
-#=================================================
|
|
|
|
|
-# CREATE A MYSQL DATABASE
|
|
|
|
|
-#=================================================
|
|
|
|
|
-ynh_script_progression --message="Creating a MySQL database..."
|
|
|
|
|
-
|
|
|
|
|
-db_name=$(ynh_sanitize_dbid --db_name=$app)
|
|
|
|
|
-db_user=$db_name
|
|
|
|
|
-ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
|
|
|
|
-ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
|
|
|
|
-
|
|
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
#=================================================
|
|
#=================================================
|
|
|
ynh_script_progression --message="Setting up source files..."
|
|
ynh_script_progression --message="Setting up source files..."
|
|
|
|
|
|
|
|
-ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
|
|
|
|
-ln -s "/usr/share/zabbix" "$final_path"
|
|
|
|
|
-
|
|
|
|
|
-chmod 750 "/usr/share/zabbix"
|
|
|
|
|
chmod -R o-rwx "/usr/share/zabbix"
|
|
chmod -R o-rwx "/usr/share/zabbix"
|
|
|
-chown -R $app:www-data "/usr/share/zabbix"
|
|
|
|
|
-
|
|
|
|
|
-#=================================================
|
|
|
|
|
-# PHP-FPM CONFIGURATION
|
|
|
|
|
-#=================================================
|
|
|
|
|
-ynh_script_progression --message="Configuring PHP-FPM..."
|
|
|
|
|
-
|
|
|
|
|
-# Create a dedicated PHP-FPM config
|
|
|
|
|
-ynh_add_fpm_config
|
|
|
|
|
-phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
|
|
|
|
-
|
|
|
|
|
-#=================================================
|
|
|
|
|
-# NGINX CONFIGURATION
|
|
|
|
|
-#=================================================
|
|
|
|
|
-ynh_script_progression --message="Configuring NGINX web server..."
|
|
|
|
|
-
|
|
|
|
|
-# Create a dedicated NGINX config
|
|
|
|
|
-ynh_add_nginx_config
|
|
|
|
|
|
|
+chown -R "$app:www-data" "/usr/share/zabbix"
|
|
|
|
|
|
|
|
-#=================================================
|
|
|
|
|
-# SPECIFIC SETUP
|
|
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# IMPORT DEFAULT DATA
|
|
# IMPORT DEFAULT DATA
|
|
|
#=================================================
|
|
#=================================================
|
|
@@ -132,8 +39,8 @@ $mysqlconn -e "INSERT INTO \`users_groups\` (\`id\`, \`usrgrpid\`, \`userid\`) V
|
|
|
|
|
|
|
|
#users creation in zabbix database
|
|
#users creation in zabbix database
|
|
|
i=4
|
|
i=4
|
|
|
-for user in $(ynh_user_list);
|
|
|
|
|
-do
|
|
|
|
|
|
|
+for user in $(ynh_user_list);
|
|
|
|
|
+do
|
|
|
if [ "$user" != "$admin" ]
|
|
if [ "$user" != "$admin" ]
|
|
|
then
|
|
then
|
|
|
surname=$(ynh_user_get_info --username="$user" --key=lastname)
|
|
surname=$(ynh_user_get_info --username="$user" --key=lastname)
|
|
@@ -155,33 +62,40 @@ ynh_script_progression --message="Adding a configuration file..."
|
|
|
ynh_add_config --template="../conf/etc_zabbix_web_zabbix.conf.php" --destination="/etc/zabbix/web/zabbix.conf.php"
|
|
ynh_add_config --template="../conf/etc_zabbix_web_zabbix.conf.php" --destination="/etc/zabbix/web/zabbix.conf.php"
|
|
|
|
|
|
|
|
chmod 400 "/etc/zabbix/web/zabbix.conf.php"
|
|
chmod 400 "/etc/zabbix/web/zabbix.conf.php"
|
|
|
-chown $app:www-data "/etc/zabbix/web/zabbix.conf.php"
|
|
|
|
|
|
|
+chown "$app:www-data" "/etc/zabbix/web/zabbix.conf.php"
|
|
|
|
|
|
|
|
ynh_replace_string --match_string="DBName=zabbix" --replace_string="DBName=$db_name" --target_file=/etc/zabbix/zabbix_server.conf
|
|
ynh_replace_string --match_string="DBName=zabbix" --replace_string="DBName=$db_name" --target_file=/etc/zabbix/zabbix_server.conf
|
|
|
ynh_replace_string --match_string="DBUser=zabbix" --replace_string="DBUser=$db_user" --target_file=/etc/zabbix/zabbix_server.conf
|
|
ynh_replace_string --match_string="DBUser=zabbix" --replace_string="DBUser=$db_user" --target_file=/etc/zabbix/zabbix_server.conf
|
|
|
ynh_replace_string --match_string="# DBPassword=" --replace_string="# DBPassword=\nDBPassword=$db_pwd" --target_file=/etc/zabbix/zabbix_server.conf
|
|
ynh_replace_string --match_string="# DBPassword=" --replace_string="# DBPassword=\nDBPassword=$db_pwd" --target_file=/etc/zabbix/zabbix_server.conf
|
|
|
|
|
|
|
|
#=================================================
|
|
#=================================================
|
|
|
-# SETUP SYSTEMD
|
|
|
|
|
|
|
+# SYSTEM CONFIGURATION
|
|
|
#=================================================
|
|
#=================================================
|
|
|
-ynh_script_progression --message="Configuring a systemd service..."
|
|
|
|
|
|
|
+ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
|
+
|
|
|
|
|
+ynh_replace_string --match_string="# $language.UTF-8 UTF-8" --replace_string="$language.UTF-8 UTF-8" --target_file=/etc/locale.gen
|
|
|
|
|
+locale-gen
|
|
|
|
|
+
|
|
|
|
|
+# Create a dedicated PHP-FPM config
|
|
|
|
|
+ynh_add_fpm_config
|
|
|
|
|
+
|
|
|
|
|
+# Create a dedicated NGINX config
|
|
|
|
|
+ynh_add_nginx_config
|
|
|
|
|
|
|
|
change_timeoutAgent
|
|
change_timeoutAgent
|
|
|
|
|
|
|
|
systemctl enable zabbix-agent --quiet
|
|
systemctl enable zabbix-agent --quiet
|
|
|
systemctl enable zabbix-server --quiet
|
|
systemctl enable zabbix-server --quiet
|
|
|
|
|
+yunohost service add snmpd --description="Management of SNMP Daemon"
|
|
|
|
|
+yunohost service add zabbix-server --description="Management Zabbix server daemon : collect, agregate, compute and notify" --log="/var/log/$app/${app}_server.log"
|
|
|
|
|
+yunohost service add zabbix-agent --description="Management Zabbix agent daemon : send informations about this host to the server" --log="/var/log/$app/${app}_agent.log"
|
|
|
|
|
|
|
|
update_initZabbixConf
|
|
update_initZabbixConf
|
|
|
|
|
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# SETUP APPLICATION WITH CURL
|
|
# SETUP APPLICATION WITH CURL
|
|
|
#=================================================
|
|
#=================================================
|
|
|
-ynh_script_progression --message="Setuping application with CURL..."
|
|
|
|
|
-
|
|
|
|
|
-# Set the app as temporarily public for curl call
|
|
|
|
|
-ynh_script_progression --message="Configuring SSOwat..."
|
|
|
|
|
-# Making the app public for curl
|
|
|
|
|
-ynh_permission_update --permission="main" --add="visitors"
|
|
|
|
|
|
|
+ynh_script_progression --message="Setting up application with CURL..."
|
|
|
|
|
|
|
|
import_template
|
|
import_template
|
|
|
|
|
|
|
@@ -189,48 +103,14 @@ link_template
|
|
|
|
|
|
|
|
disable_admin_user
|
|
disable_admin_user
|
|
|
|
|
|
|
|
-# Remove the public access
|
|
|
|
|
-ynh_permission_update --permission="main" --remove="visitors"
|
|
|
|
|
-
|
|
|
|
|
-#=================================================
|
|
|
|
|
-# GENERIC FINALIZATION
|
|
|
|
|
-#=================================================
|
|
|
|
|
-# INTEGRATE SERVICE IN YUNOHOST
|
|
|
|
|
-#=================================================
|
|
|
|
|
-ynh_script_progression --message="Integrating service in YunoHost..."
|
|
|
|
|
-
|
|
|
|
|
-yunohost service add snmpd --description="Management of SNMP Daemon"
|
|
|
|
|
-yunohost service add zabbix-server --description="Management Zabbix server daemon : collect, agregate, compute and notify" --log="/var/log/$app/${app}_server.log"
|
|
|
|
|
-yunohost service add zabbix-agent --description="Management Zabbix agent daemon : send informations about this host to the server" --log="/var/log/$app/${app}_agent.log"
|
|
|
|
|
-
|
|
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# START SYSTEMD SERVICE
|
|
# START SYSTEMD SERVICE
|
|
|
#=================================================
|
|
#=================================================
|
|
|
-ynh_script_progression --message="Starting a systemd service..."
|
|
|
|
|
|
|
+ynh_script_progression --message="Starting $app's systemd service..."
|
|
|
|
|
|
|
|
# Start a systemd service
|
|
# Start a systemd service
|
|
|
-ynh_systemd_action --service_name=$app-server --action="restart" --log_path="/var/log/$app/${app}_server.log"
|
|
|
|
|
-ynh_systemd_action --service_name=$app-agent --action="restart" --log_path="/var/log/$app/${app}_agent.log"
|
|
|
|
|
-
|
|
|
|
|
-#=================================================
|
|
|
|
|
-# SETUP SSOWAT
|
|
|
|
|
-#=================================================
|
|
|
|
|
-ynh_script_progression --message="Configuring permissions..."
|
|
|
|
|
-
|
|
|
|
|
-# Make app public if necessary
|
|
|
|
|
-if [ $is_public -eq 1 ]
|
|
|
|
|
-then
|
|
|
|
|
- # Everyone can access the app.
|
|
|
|
|
- # The "main" permission is automatically created before the install script.
|
|
|
|
|
- ynh_permission_update --permission="main" --add="visitors"
|
|
|
|
|
-fi
|
|
|
|
|
-
|
|
|
|
|
-#=================================================
|
|
|
|
|
-# RELOAD NGINX
|
|
|
|
|
-#=================================================
|
|
|
|
|
-ynh_script_progression --message="Reloading NGINX web server..."
|
|
|
|
|
-
|
|
|
|
|
-ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
|
|
|
+ynh_systemd_action --service_name="$app-server" --action="restart" --log_path="/var/log/$app/${app}_server.log"
|
|
|
|
|
+ynh_systemd_action --service_name="$app-agent" --action="restart" --log_path="/var/log/$app/${app}_agent.log"
|
|
|
|
|
|
|
|
#=================================================
|
|
#=================================================
|
|
|
# END OF SCRIPT
|
|
# END OF SCRIPT
|