mirror of
https://github.com/YunoHost-Apps/zabbix_ynh.git
synced 2024-09-03 20:36:14 +02:00
[autopatch] Automatic patch attempt for helpers 2.1
This commit is contained in:
parent
2791ab2912
commit
756648bf3a
10 changed files with 135 additions and 137 deletions
|
@ -12,7 +12,7 @@ location __PATH__/ {
|
|||
try_files $uri $uri/ index.php;
|
||||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
|
||||
fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__APP__.sock;
|
||||
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; Start a new pool named 'www'.
|
||||
; the variable $pool can be used in any directive and will be replaced by the
|
||||
; pool name ('www' here)
|
||||
[__NAMETOCHANGE__]
|
||||
[__APP__]
|
||||
|
||||
; Per pool prefix
|
||||
; It only applies on the following directives:
|
||||
|
@ -20,8 +20,8 @@
|
|||
; Unix user/group of processes
|
||||
; Note: The user is mandatory. If the group is not set, the default user's group
|
||||
; will be used.
|
||||
user = __USER__
|
||||
group = __USER__
|
||||
user = __APP__
|
||||
group = __APP__
|
||||
|
||||
; The address on which to accept FastCGI requests.
|
||||
; Valid syntaxes are:
|
||||
|
@ -33,7 +33,7 @@ group = __USER__
|
|||
; (IPv6 and IPv4-mapped) on a specific port;
|
||||
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||
; Note: This value is mandatory.
|
||||
listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock
|
||||
listen = /var/run/php/php__PHP_VERSION__-fpm-__APP__.sock
|
||||
|
||||
; Set listen(2) backlog.
|
||||
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
|
||||
|
@ -320,7 +320,7 @@ pm.max_requests = 500
|
|||
; The log file for slow requests
|
||||
; Default Value: not set
|
||||
; Note: slowlog is mandatory if request_slowlog_timeout is set
|
||||
slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log
|
||||
slowlog = /var/log/nginx/__APP__.slow.log
|
||||
|
||||
; The timeout for serving a single request after which a PHP backtrace will be
|
||||
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
|
||||
|
|
|
@ -19,7 +19,8 @@ code = "https://github.com/zabbix/zabbix"
|
|||
cpe = "cpe:2.3:a:zabbix:zabbix"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.2"
|
||||
yunohost = ">= 11.2.18"
|
||||
helpers_version = "2.1"
|
||||
architectures = ["amd64"]
|
||||
multi_instance = false
|
||||
ldap = true
|
||||
|
@ -56,6 +57,7 @@ ram.runtime = "200M"
|
|||
[resources.system_user]
|
||||
|
||||
[resources.install_dir]
|
||||
group = "www-data:r-x"
|
||||
|
||||
[resources.permissions]
|
||||
main.url = "/"
|
||||
|
|
|
@ -13,13 +13,13 @@ get_state_guest_user () {
|
|||
disable_guest_user () {
|
||||
if [ $(get_state_guest_user) = "0" ]
|
||||
then
|
||||
ynh_print_info --message="Disable guest user"
|
||||
ynh_print_info "Disable guest user"
|
||||
lastid=$($mysqlconn -BN -e "SELECT max(id) from \`users_groups\`")
|
||||
lastid=$(("$lastid" + 1 ))
|
||||
$mysqlconn -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 2);"
|
||||
ynh_print_info --message="Guest user disabled"
|
||||
ynh_print_info "Guest user disabled"
|
||||
else
|
||||
ynh_print_info --message="Guest user already disabled"
|
||||
ynh_print_info "Guest user already disabled"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -36,13 +36,13 @@ get_state_admin_user () {
|
|||
disable_admin_user () {
|
||||
if [ $(get_state_admin_user) = "0" ]
|
||||
then
|
||||
ynh_print_info --message="Disable admin user"
|
||||
ynh_print_info "Disable admin user"
|
||||
lastid=$($mysqlconn -BN -e "SELECT max(id) from \`users_groups\`")
|
||||
lastid=$((lastid + 1 ))
|
||||
$mysqlconn -e "INSERT INTO \`users_groups\` (\`id\` , \`usrgrpid\`, \`userid\`) VALUES ($lastid ,9, 1);"
|
||||
ynh_print_info --message="Admin user disabled"
|
||||
ynh_print_info "Admin user disabled"
|
||||
else
|
||||
ynh_print_info --message="Admin user already disabled"
|
||||
ynh_print_info "Admin user already disabled"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -51,19 +51,19 @@ disable_admin_user () {
|
|||
enable_admin_user () {
|
||||
if [ $(get_state_admin_user) = "1" ]
|
||||
then
|
||||
ynh_print_info --message="Enable admin user"
|
||||
ynh_print_info "Enable admin user"
|
||||
#enable default admin temporaly
|
||||
$mysqlconn -e "DELETE FROM users_groups where usrgrpid=9 and userid=1;"
|
||||
ynh_print_info --message="Admin user enabled"
|
||||
ynh_print_info "Admin user enabled"
|
||||
else
|
||||
ynh_print_info --message="Admin user already enable"
|
||||
ynh_print_info "Admin user already enable"
|
||||
fi
|
||||
}
|
||||
|
||||
# Import YunoHost template in the agent
|
||||
#
|
||||
import_template () {
|
||||
ynh_print_info --message="Import YunoHost template in the agent"
|
||||
ynh_print_info "Import YunoHost template in the agent"
|
||||
zabbixFullpath=https://$domain$path
|
||||
localpath="../conf/Template_Yunohost.xml"
|
||||
sudoUserPpath="../conf/etc_sudoers.d_zabbix"
|
||||
|
@ -71,7 +71,7 @@ import_template () {
|
|||
bashUserPpath="../conf/etc_zabbix_zabbix_agentd.d_yunohost.sh"
|
||||
|
||||
cp "$sudoUserPpath" /etc/sudoers.d/zabbix
|
||||
chmod 400 /etc/sudoers.d/zabbix
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 /etc/sudoers.d/zabbix
|
||||
|
||||
if [ -d /etc/zabbix/zabbix_agentd.d ]
|
||||
then
|
||||
|
@ -94,7 +94,7 @@ import_template () {
|
|||
if [[ $visitors_enabled == "no" ]]; then
|
||||
ynh_permission_update --permission "main" --add "visitors"
|
||||
fi
|
||||
|
||||
|
||||
curlOptions="--noproxy $domain -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt --resolve $domain:443:127.0.0.1"
|
||||
|
||||
curl -L $curlOptions \
|
||||
|
@ -139,12 +139,12 @@ import_template () {
|
|||
|
||||
if [ "$importState" -eq "1" ]
|
||||
then
|
||||
ynh_print_info --message="YunoHost template imported !"
|
||||
ynh_print_info "YunoHost template imported !"
|
||||
else
|
||||
ynh_print_warn --message="YunoHost template not imported !"
|
||||
ynh_print_warn "YunoHost template not imported !"
|
||||
fi
|
||||
else
|
||||
ynh_print_warn --message="Admin user cannot connect to the interface !"
|
||||
ynh_print_warn "Admin user cannot connect to the interface !"
|
||||
fi
|
||||
|
||||
if [[ $visitors_enabled == "no" ]]; then
|
||||
|
@ -155,7 +155,7 @@ import_template () {
|
|||
# Link YunoHost template to Zabbix server
|
||||
#
|
||||
link_template () {
|
||||
ynh_print_info --message="Link YunoHost template to Zabbix server"
|
||||
ynh_print_info "Link YunoHost template to Zabbix server"
|
||||
|
||||
# Temporarily enable visitors if needed...
|
||||
local visitors_enabled=$(ynh_permission_has_user "main" "visitors" && echo yes || echo no)
|
||||
|
@ -170,9 +170,9 @@ link_template () {
|
|||
applyTemplate=$(curl --noproxy $domain -k -s --resolve $domain:443:127.0.0.1 --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","method":"host.massadd","params":{"hosts":[{"hostid":"'"$zabbixHostID"'"}],"templates":[{"templateid":"'"$zabbixTemplateID"'"}]},"auth":"'"$tokenapi"'","id":1}' "${zabbixFullpath}/api_jsonrpc.php" | jq -r '.result.hostids[]')
|
||||
if [ "$applyTemplate" -eq "$zabbixHostID" ]
|
||||
then
|
||||
ynh_print_info --message="YunoHost template linked to Zabbix server !"
|
||||
ynh_print_info "YunoHost template linked to Zabbix server !"
|
||||
else
|
||||
ynh_print_warn --message="YunoHost template not linked to Zabbix server !"
|
||||
ynh_print_warn "YunoHost template not linked to Zabbix server !"
|
||||
fi
|
||||
|
||||
if [[ $visitors_enabled == "no" ]]; then
|
||||
|
@ -186,10 +186,10 @@ check_proc_zabbixserver () {
|
|||
pgrep zabbix_server >/dev/null
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
ynh_print_info --message="Zabbix server is started !"
|
||||
ynh_print_info "Zabbix server is started !"
|
||||
else
|
||||
ynh_print_err --message="Zabbix server not started, try to start it with the YunoHost interface."
|
||||
ynh_print_err --message="If Zabbix server can't start, please open a issue on https://github.com/YunoHost-Apps/zabbix_ynh/issues"
|
||||
ynh_print_warn "Zabbix server not started, try to start it with the YunoHost interface."
|
||||
ynh_print_warn "If Zabbix server can't start, please open a issue on https://github.com/YunoHost-Apps/zabbix_ynh/issues"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -199,18 +199,17 @@ check_proc_zabbixagent () {
|
|||
pgrep zabbix_agentd >/dev/null
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
ynh_print_info --message="Zabbix agent is started"
|
||||
ynh_print_info "Zabbix agent is started"
|
||||
else
|
||||
ynh_print_err --message="Zabbix agent not started, try to start it with the YunoHost interface."
|
||||
ynh_print_err --message="If Zabbix agent can't start, please open a issue on https://github.com/YunoHost-Apps/zabbix_ynh/issues"
|
||||
ynh_print_warn "Zabbix agent not started, try to start it with the YunoHost interface."
|
||||
ynh_print_warn "If Zabbix agent can't start, please open a issue on https://github.com/YunoHost-Apps/zabbix_ynh/issues"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Update Zabbix configuration initialisation
|
||||
#
|
||||
update_initZabbixConf () {
|
||||
ynh_print_info --message="Update Zabbix configuration initialisation !"
|
||||
ynh_print_info "Update Zabbix configuration initialisation !"
|
||||
if [ ! -d /etc/zabbix/web ]
|
||||
then
|
||||
mkdir -p /etc/zabbix/web
|
||||
|
@ -218,22 +217,22 @@ update_initZabbixConf () {
|
|||
cp "../conf/etc_zabbix_web_init.zabbix.conf.php.sh" /etc/zabbix/web/init.zabbix.conf.php.sh
|
||||
chmod 700 /etc/zabbix/web/init.zabbix.conf.php.sh
|
||||
cp "../conf/etc_apt_apt.conf.d_100update_force_init_zabbix_frontend_config" /etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config
|
||||
ynh_print_info --message="Zabbix configuration initialisation updated !"
|
||||
ynh_print_info "Zabbix configuration initialisation updated !"
|
||||
}
|
||||
|
||||
# Delete Zabbix configuration initialisation
|
||||
#
|
||||
delete_initZabbixConf () {
|
||||
ynh_print_info --message="Delete Zabbix configuration initialisation !"
|
||||
ynh_print_info "Delete Zabbix configuration initialisation !"
|
||||
if [ -f /etc/zabbix/web/init.zabbix.conf.php.sh ]
|
||||
then
|
||||
ynh_secure_remove --file="/etc/zabbix/web/init.zabbix.conf.php.sh"
|
||||
ynh_safe_rm "/etc/zabbix/web/init.zabbix.conf.php.sh"
|
||||
fi
|
||||
if [ -f /etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config ]
|
||||
then
|
||||
ynh_secure_remove --file="/etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config"
|
||||
ynh_safe_rm "/etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config"
|
||||
fi
|
||||
ynh_print_info --message="Zabbix configuration initialisation deleted !"
|
||||
ynh_print_info "Zabbix configuration initialisation deleted !"
|
||||
}
|
||||
|
||||
# Patch timeout too short for Zabbix agent if needed
|
||||
|
@ -242,23 +241,23 @@ change_timeoutAgent () {
|
|||
timeout_ok=$(grep "^Timeout" /etc/zabbix/zabbix_agentd.conf 2>/dev/null || true;)
|
||||
if [ -z "$timeout_ok" ]
|
||||
then
|
||||
ynh_replace_string --match_string="# Timeout=3" --replace_string="Timeout=10" --target_file=/etc/zabbix/zabbix_agentd.conf
|
||||
ynh_replace --match="# Timeout=3" --replace="Timeout=10" --file=/etc/zabbix/zabbix_agentd.conf
|
||||
grep -C 2 "Timeout" /etc/zabbix/zabbix_agentd.conf
|
||||
systemctl restart zabbix-agent
|
||||
ynh_print_info --message="Zabbix agent timeout updated !"
|
||||
ynh_print_info "Zabbix agent timeout updated !"
|
||||
fi
|
||||
}
|
||||
|
||||
# Update Zabbix database character set
|
||||
#
|
||||
convert_ZabbixDB () {
|
||||
ynh_print_info --message="Zabbix database character set will be updated !"
|
||||
ynh_print_info "Zabbix database character set will be updated !"
|
||||
$mysqlconn -e "ALTER DATABASE $db_name CHARACTER SET utf8 COLLATE utf8_general_ci;"
|
||||
for t in $($mysqlconn -BN -e "show tables";)
|
||||
do
|
||||
$mysqlconn -e "ALTER TABLE $t CONVERT TO character set utf8 collate utf8_bin;"
|
||||
done
|
||||
ynh_print_info --message="Zabbix database character set has been updated !"
|
||||
ynh_print_info "Zabbix database character set has been updated !"
|
||||
}
|
||||
|
||||
# Add email media type with the YunoHost server mail.
|
||||
|
@ -268,7 +267,7 @@ set_mediatype_default_yunohost () {
|
|||
if [ $($mysqlconn -BN -e "SELECT count(*) FROM media_type WHERE smtp_server LIKE 'mail.example.com' AND status=1;") -eq 1 ]
|
||||
then
|
||||
$mysqlconn -BN -e "UPDATE media_type SET smtp_server = 'localhost', smtp_helo = '"$domain"', smtp_email = 'zabbix@"$domain"', smtp_port = '587', status=0 , smtp_security=1 WHERE smtp_server LIKE 'mail.example.com' AND status=1;"
|
||||
ynh_print_info --message="Default Media type added !"
|
||||
ynh_print_info "Default Media type added !"
|
||||
fi
|
||||
set +x
|
||||
}
|
||||
|
|
|
@ -8,46 +8,43 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
ynh_print_info "Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
# Backup frontend config
|
||||
ynh_backup --src_path="/etc/zabbix/web"
|
||||
ynh_backup --src_path="/etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config"
|
||||
ynh_backup "/etc/zabbix/web"
|
||||
ynh_backup "/etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config"
|
||||
|
||||
# Backup server config
|
||||
ynh_backup --src_path="/etc/zabbix/zabbix_server.conf"
|
||||
ynh_backup "/etc/zabbix/zabbix_server.conf"
|
||||
|
||||
# Backup agent config
|
||||
ynh_backup --src_path="/etc/zabbix/zabbix_agentd.conf"
|
||||
ynh_backup --src_path="/etc/zabbix/zabbix_agentd.d"
|
||||
ynh_backup "/etc/zabbix/zabbix_agentd.conf"
|
||||
ynh_backup "/etc/zabbix/zabbix_agentd.d"
|
||||
|
||||
# Backup sudo file
|
||||
ynh_backup --src_path="/etc/sudoers.d/zabbix"
|
||||
ynh_backup "/etc/sudoers.d/zabbix"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the MySQL database..."
|
||||
ynh_print_info "Backing up the MySQL database..."
|
||||
|
||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||
ynh_mysql_dump_db > db.sql
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -10,12 +10,12 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..."
|
||||
ynh_script_progression "Updating NGINX web server configuration..."
|
||||
|
||||
ynh_change_url_nginx_config
|
||||
ynh_config_change_url_nginx
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app"
|
||||
ynh_script_progression "Change of URL completed for $app"
|
||||
|
|
|
@ -10,7 +10,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..."
|
||||
ynh_script_progression "Setting up source files..."
|
||||
|
||||
chmod -R o-rwx "/usr/share/zabbix"
|
||||
chown -R "$app:www-data" "/usr/share/zabbix"
|
||||
|
@ -18,9 +18,10 @@ chown -R "$app:www-data" "/usr/share/zabbix"
|
|||
#=================================================
|
||||
# IMPORT DEFAULT DATA
|
||||
#=================================================
|
||||
ynh_script_progression --message="Import default data in database..."
|
||||
ynh_script_progression "Import default data in database..."
|
||||
|
||||
export mysqlconn="mysql --user=$db_user --password=$db_pwd
|
||||
|
||||
export mysqlconn="mysql --user=$db_user --password=$db_pwd --database=$db_name"
|
||||
$mysqlconn -e "ALTER DATABASE $db_name CHARACTER SET utf8 COLLATE utf8_general_ci;"
|
||||
|
||||
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | $mysqlconn
|
||||
|
@ -57,30 +58,30 @@ set_mediatype_default_yunohost
|
|||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..."
|
||||
ynh_script_progression "Adding $app's configuration..."
|
||||
|
||||
ynh_add_config --template="../conf/etc_zabbix_web_zabbix.conf.php" --destination="/etc/zabbix/web/zabbix.conf.php"
|
||||
ynh_config_add --template="etc_zabbix_web_zabbix.conf.php" --destination="/etc/zabbix/web/zabbix.conf.php"
|
||||
|
||||
chmod 400 "/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="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 --match="DBName=zabbix" --replace="DBName=$db_name" --file=/etc/zabbix/zabbix_server.conf
|
||||
ynh_replace --match="DBUser=zabbix" --replace="DBUser=$db_user" --file=/etc/zabbix/zabbix_server.conf
|
||||
ynh_replace --match="# DBPassword=" --replace="# DBPassword=\nDBPassword=$db_pwd" --file=/etc/zabbix/zabbix_server.conf
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Adding system configurations related to $app..."
|
||||
|
||||
ynh_replace_string --match_string="# $language.UTF-8 UTF-8" --replace_string="$language.UTF-8 UTF-8" --target_file=/etc/locale.gen
|
||||
ynh_replace --match="# $language.UTF-8 UTF-8" --replace="$language.UTF-8 UTF-8" --file=/etc/locale.gen
|
||||
locale-gen
|
||||
|
||||
# Create a dedicated PHP-FPM config
|
||||
ynh_add_fpm_config
|
||||
ynh_config_add_phpfpm
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
change_timeoutAgent
|
||||
|
||||
|
@ -95,7 +96,7 @@ update_initZabbixConf
|
|||
#=================================================
|
||||
# SETUP APPLICATION WITH CURL
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up application with CURL..."
|
||||
ynh_script_progression "Setting up application with CURL..."
|
||||
|
||||
import_template
|
||||
|
||||
|
@ -106,14 +107,14 @@ disable_admin_user
|
|||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting $app's systemd service..."
|
||||
ynh_script_progression "Starting $app's 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"
|
||||
ynh_systemctl --service="$app-server" --action="restart" --log_path="/var/log/$app/${app}_server.log"
|
||||
ynh_systemctl --service="$app-agent" --action="restart" --log_path="/var/log/$app/${app}_agent.log"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed"
|
||||
ynh_script_progression "Installation of $app completed"
|
||||
|
|
|
@ -10,60 +10,60 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Removing system configurations related to $app..."
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_systemd_action --service_name="$app-server" --action="stop" --log_path="/var/log/$app/${app}_server.log"
|
||||
ynh_systemd_action --service_name="$app-agent" --action="stop" --log_path="/var/log/$app/${app}_agent.log"
|
||||
ynh_systemctl --service="$app-server" --action="stop" --log_path="/var/log/$app/${app}_server.log"
|
||||
ynh_systemctl --service="$app-agent" --action="stop" --log_path="/var/log/$app/${app}_agent.log"
|
||||
systemctl disable zabbix-server --quiet
|
||||
systemctl disable zabbix-agent --quiet
|
||||
ynh_exec_warn_less killall zabbix_server
|
||||
ynh_exec_warn_less killall zabbix_agentd
|
||||
ynh_hide_warnings killall zabbix_server
|
||||
ynh_hide_warnings killall zabbix_agentd
|
||||
|
||||
yunohost service remove snmpd
|
||||
yunohost service remove zabbix-server
|
||||
yunohost service remove zabbix-agent
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
ynh_config_remove_nginx
|
||||
|
||||
# Remove the dedicated PHP-FPM config
|
||||
ynh_remove_fpm_config
|
||||
ynh_config_remove_phpfpm
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing $app's configuration..."
|
||||
ynh_script_progression "Removing $app's configuration..."
|
||||
|
||||
# Remove config file detection
|
||||
delete_initZabbixConf
|
||||
|
||||
ynh_secure_remove --file="/usr/share/$app"
|
||||
ynh_safe_rm "/usr/share/$app"
|
||||
|
||||
#=================================================
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing various files..."
|
||||
ynh_script_progression "Removing various files..."
|
||||
|
||||
# Remove a directory securely
|
||||
ynh_secure_remove --file="/etc/$app"
|
||||
ynh_safe_rm "/etc/$app"
|
||||
|
||||
# Remove the log files
|
||||
|
||||
ynh_secure_remove --file="/run/$app"
|
||||
ynh_safe_rm "/run/$app"
|
||||
|
||||
ynh_secure_remove --file="/etc/sudoers.d/$app"
|
||||
ynh_safe_rm "/etc/sudoers.d/$app"
|
||||
|
||||
# FIXME: useless?
|
||||
# REMOVE NONFREE PART PATCH IF NEEDED (snmp-mibs-downloader (non-free) installed in version 1)
|
||||
nonfreepackagelist=$(dpkg-query -W -f='${Section}\t${Package}\n' | grep ^non-free)
|
||||
if [ "$(echo $nonfreepackagelist | wc -l)" -eq 1 ] && [ "$(echo $nonfreepackagelist | grep -c "snmp-mibs-downloader")" -eq 1 ]; then
|
||||
ynh_print_info --message="Removing snmp-mibs-downloader (non-free package)"
|
||||
ynh_print_info "Removing snmp-mibs-downloader (non-free package)"
|
||||
cp /var/lib/dpkg/status{,.$(date "+%m%d%y")}
|
||||
ynh_replace_string --match_string=" snmp-mibs-downloader," --replace_string="" --target_file=/var/lib/dpkg/status
|
||||
ynh_replace --match=" snmp-mibs-downloader," --replace="" --file=/var/lib/dpkg/status
|
||||
DEBIAN_FRONTEND=noninteractive apt purge snmp-mibs-downloader -y
|
||||
if [ -f /etc/apt/sources.list.d/non-free.list ]; then
|
||||
ynh_secure_remove --file="/etc/apt/sources.list.d/non-free.list"
|
||||
ynh_safe_rm "/etc/apt/sources.list.d/non-free.list"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -71,4 +71,4 @@ fi
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed"
|
||||
ynh_script_progression "Removal of $app completed"
|
||||
|
|
|
@ -11,7 +11,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
ynh_script_progression "Restoring the app main directory..."
|
||||
|
||||
chmod -R o-rwx "/usr/share/zabbix"
|
||||
chown -R "$app:www-data" "/usr/share/zabbix"
|
||||
|
@ -19,49 +19,50 @@ chown -R "$app:www-data" "/usr/share/zabbix"
|
|||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
|
||||
ynh_script_progression "Restoring the MySQL database..."
|
||||
|
||||
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
|
||||
ynh_mysql_db_shell < ./db.sql
|
||||
|
||||
export mysqlconn="mysql --user=$db_user --password=$db_pwd
|
||||
|
||||
export mysqlconn="mysql --user=$db_user --password=$db_pwd --database=$db_name"
|
||||
convert_ZabbixDB
|
||||
|
||||
#=================================================
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring various files..."
|
||||
ynh_script_progression "Restoring various files..."
|
||||
|
||||
if [ -f "/etc/zabbix/web/zabbix.conf.php" ]; then
|
||||
ynh_secure_remove --file="/etc/zabbix/web/zabbix.conf.php"
|
||||
ynh_safe_rm "/etc/zabbix/web/zabbix.conf.php"
|
||||
fi
|
||||
ynh_restore_file --origin_path="/etc/zabbix/web/zabbix.conf.php"
|
||||
ynh_restore "/etc/zabbix/web/zabbix.conf.php"
|
||||
|
||||
chmod 400 "/etc/zabbix/web/zabbix.conf.php"
|
||||
chown "$app:www-data" "/etc/zabbix/web/zabbix.conf.php"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config"
|
||||
ynh_restore "/etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/zabbix/zabbix_server.conf"
|
||||
ynh_restore_file --origin_path="/etc/zabbix/zabbix_agentd.conf"
|
||||
ynh_restore "/etc/zabbix/zabbix_server.conf"
|
||||
ynh_restore "/etc/zabbix/zabbix_agentd.conf"
|
||||
|
||||
if [ ! -L /etc/zabbix/zabbix_agentd.d ]; then
|
||||
ln -s /etc/zabbix/zabbix_agentd.conf.d /etc/zabbix/zabbix_agentd.d
|
||||
fi
|
||||
|
||||
# Restore sudo file
|
||||
ynh_restore_file --origin_path="/etc/sudoers.d/zabbix"
|
||||
ynh_restore "/etc/sudoers.d/zabbix"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Restoring system configurations related to $app..."
|
||||
|
||||
ynh_replace_string --match_string="# $language.UTF-8 UTF-8" --replace_string="$language.UTF-8 UTF-8" --target_file=/etc/locale.gen
|
||||
ynh_replace --match="# $language.UTF-8 UTF-8" --replace="$language.UTF-8 UTF-8" --file=/etc/locale.gen
|
||||
locale-gen
|
||||
|
||||
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
ynh_restore "/etc/php/$php_version/fpm/pool.d/$app.conf"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
change_timeoutAgent
|
||||
|
||||
|
@ -74,17 +75,17 @@ yunohost service add zabbix-agent --description="Management Zabbix agent daemon
|
|||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
||||
ynh_script_progression "Reloading NGINX web server and $app's 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"
|
||||
ynh_systemctl --service="$app-server" --action="restart" --log_path="/var/log/$app/${app}_server.log"
|
||||
ynh_systemctl --service="$app-agent" --action="restart" --log_path="/var/log/$app/${app}_agent.log"
|
||||
|
||||
ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
ynh_systemctl --service="php$php_version-fpm" --action=reload
|
||||
ynh_systemctl --service=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app"
|
||||
ynh_script_progression "Restoration completed for $app"
|
||||
|
|
|
@ -10,47 +10,47 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping $app's systemd service..."
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name="$app-server" --action="stop" --log_path="/var/log/$app/${app}_server.log"
|
||||
ynh_systemd_action --service_name="$app-agent" --action="stop" --log_path="/var/log/$app/${app}_agent.log"
|
||||
ynh_systemctl --service="$app-server" --action="stop" --log_path="/var/log/$app/${app}_server.log"
|
||||
ynh_systemctl --service="$app-agent" --action="stop" --log_path="/var/log/$app/${app}_agent.log"
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
ynh_script_progression "Ensuring downward compatibility..."
|
||||
|
||||
if [ "$language" == "fr" ]; then
|
||||
language="fr_FR"
|
||||
ynh_app_setting_set --app="$app" --key="language" --value="$language"
|
||||
ynh_app_setting_set --key="language" --value="$language"
|
||||
fi
|
||||
|
||||
if [ "$language" == "en" ]; then
|
||||
language="en_GB"
|
||||
ynh_app_setting_set --app="$app" --key="language" --value="$language"
|
||||
ynh_app_setting_set --key="language" --value="$language"
|
||||
fi
|
||||
|
||||
export mysqlconn="mysql --user=$db_user --password=$db_pwd --database=$db_name"
|
||||
export mysqlconn="mysql --user=$db_user --password=$db_pwd
|
||||
|
||||
# patch to remove old zabbix-client service
|
||||
if yunohost service status | grep zabbix-client; then
|
||||
ynh_script_progression --message="remove zabbix-client old service"
|
||||
ynh_script_progression "remove zabbix-client old service"
|
||||
yunohost service remove zabbix-client
|
||||
fi
|
||||
|
||||
ynh_remove_logrotate
|
||||
ynh_config_remove_logrotate
|
||||
|
||||
# Check if new zabbix version is available on repo"
|
||||
|
||||
ynh_package_update
|
||||
|
||||
ynh_add_config --template="../conf/etc_zabbix_web_zabbix.conf.php" --destination="/etc/zabbix/web/zabbix.conf.php"
|
||||
ynh_config_add --template="etc_zabbix_web_zabbix.conf.php" --destination="/etc/zabbix/web/zabbix.conf.php"
|
||||
|
||||
chmod 400 "/etc/zabbix/web/zabbix.conf.php"
|
||||
chown "$app:www-data" "/etc/zabbix/web/zabbix.conf.php"
|
||||
|
||||
if [ -f "/usr/share/zabbix/conf/zabbix.conf.php" ]; then
|
||||
ynh_secure_remove --file="/usr/share/zabbix/conf/zabbix.conf.php"
|
||||
ynh_safe_rm "/usr/share/zabbix/conf/zabbix.conf.php"
|
||||
fi
|
||||
|
||||
ln -s "/etc/zabbix/web/zabbix.conf.php" "/usr/share/zabbix/conf/zabbix.conf.php"
|
||||
|
@ -61,12 +61,10 @@ chmod 750 "/usr/share/zabbix"
|
|||
chmod -R o-rwx "/usr/share/zabbix"
|
||||
chown -R "$app:www-data" "/usr/share/zabbix"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# CUSTOMIZE DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Customize the database..."
|
||||
ynh_script_progression "Customize the database..."
|
||||
|
||||
convert_ZabbixDB
|
||||
|
||||
|
@ -75,13 +73,13 @@ set_mediatype_default_yunohost
|
|||
#=================================================
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Upgrading system configurations related to $app..."
|
||||
|
||||
# Create a dedicated PHP-FPM config
|
||||
ynh_add_fpm_config
|
||||
ynh_config_add_phpfpm
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
change_timeoutAgent
|
||||
|
||||
|
@ -96,14 +94,14 @@ update_initZabbixConf
|
|||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name="$app-server" --action="restart" --log_path="/var/log/$app/${app}_server.log" --line_match="server #0 started"
|
||||
ynh_systemd_action --service_name="$app-agent" --action="restart" --log_path="/var/log/$app/${app}_agent.log"
|
||||
ynh_systemctl --service="$app-server" --action="restart" --log_path="/var/log/$app/${app}_server.log" --wait_until="server #0 started"
|
||||
ynh_systemctl --service="$app-agent" --action="restart" --log_path="/var/log/$app/${app}_agent.log"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed"
|
||||
ynh_script_progression "Upgrade of $app completed"
|
||||
|
|
Loading…
Add table
Reference in a new issue