upgrade 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/bin/bash
  2. #=================================================
  3. # GENERIC START
  4. #=================================================
  5. # IMPORT GENERIC HELPERS
  6. #=================================================
  7. source _common.sh
  8. source /usr/share/yunohost/helpers
  9. #=================================================
  10. # LOAD SETTINGS
  11. #=================================================
  12. app=$YNH_APP_INSTANCE_NAME
  13. domain=$(ynh_app_setting_get $app domain)
  14. path_url=$(ynh_app_setting_get $app path)
  15. admin=$(ynh_app_setting_get $app admin)
  16. is_public=$(ynh_app_setting_get $app is_public)
  17. final_path=$(ynh_app_setting_get $app final_path)
  18. language=$(ynh_app_setting_get $app language)
  19. db_name=$(ynh_app_setting_get $app db_name)
  20. #=================================================
  21. # ENSURE DOWNWARD COMPATIBILITY
  22. #=================================================
  23. # Fix is_public as a boolean value
  24. if [ "$is_public" = "Yes" ]; then
  25. ynh_app_setting_set $app is_public 1
  26. is_public=1
  27. elif [ "$is_public" = "No" ]; then
  28. ynh_app_setting_set $app is_public 0
  29. is_public=0
  30. fi
  31. # If db_name doesn't exist, create it
  32. if [ -z $db_name ]; then
  33. db_name=$(ynh_sanitize_dbid $app)
  34. ynh_app_setting_set $app db_name $db_name
  35. fi
  36. # If final_path doesn't exist, create it
  37. if [ -z $final_path ]; then
  38. final_path=/var/www/$app
  39. ynh_app_setting_set $app final_path $final_path
  40. fi
  41. #=================================================
  42. # CHECK THE PATH
  43. #=================================================
  44. # Normalize the URL path syntax
  45. path_url=$(ynh_normalize_url_path $path_url)
  46. #=================================================
  47. # STANDARD UPGRADE STEPS
  48. #=================================================
  49. ynh_package_update
  50. zabbixServerInstalledVersion=$(apt-cache policy zabbix-server-mysql | grep -Po "Installed: \K(.*)")
  51. zabbixServerCandidateVersion=$(apt-cache policy zabbix-server-mysql | grep -Po "Candidate: \K(.*)")
  52. zabbixFrontendInstalledVersion=$(apt-cache policy zabbix-frontend-php | grep -Po "Installed: \K(.*)")
  53. zabbixFrontendCandidateVersion=$(apt-cache policy zabbix-frontend-php | grep -Po "Candidate: \K(.*)")
  54. zabbixagentInstalledVersion=$(apt-cache policy zabbix-agent | grep -Po "Installed: \K(.*)")
  55. zabbixagentCandidateVersion=$(apt-cache policy zabbix-agent | grep -Po "Candidate: \K(.*)")
  56. if [ "$zabbixServerInstalledVersion" != "$zabbixServerCandidateVersion" -o "$zabbixFrontendInstalledVersion" != "$zabbixFrontendCandidateVersion" -o "$zabbixagentInstalledVersion" != "$zabbixagentCandidateVersion" ]
  57. then
  58. #=================================================
  59. # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
  60. #=================================================
  61. # Backup the current version of the app
  62. ynh_backup_before_upgrade
  63. ynh_clean_setup () {
  64. # restore it if the upgrade fails
  65. ynh_restore_upgradebackup
  66. }
  67. # Exit if an error occurs during the execution of the script
  68. ynh_abort_if_errors
  69. cp -rp /etc/zabbix /tmp/
  70. cp -p /usr/share/zabbix/conf/zabbix.conf.php /tmp/
  71. DEBIAN_FRONTEND=noninteractive apt-mark unhold zabbix-server-mysql zabbix-frontend-php
  72. DEBIAN_FRONTEND=noninteractive apt-get -y download zabbix-frontend-php
  73. ar x *.deb
  74. tar xzf control.tar.gz
  75. sed -i 's/apache2 | httpd, //' control
  76. tar --ignore-failed-read -cvzf control.tar.gz {post,pre}{inst,rm} md5sums control
  77. ar rcs zabbix-frontend-php+stretch_all-noapache2.deb debian-binary control.tar.gz data.tar.xz
  78. dpkg -i zabbix-frontend-php+stretch_all-noapache2.deb
  79. rm -fr zabbix-*.deb
  80. apt-get -y --only-upgrade install zabbix-server-mysql zabbix-agent
  81. DEBIAN_FRONTEND=noninteractive apt-mark hold zabbix-server-mysql zabbix-frontend-php
  82. rm /usr/share/zabbix/conf/zabbix.conf.php
  83. cp -rpf /tmp/zabbix /etc/
  84. cp -pf /tmp/zabbix.conf.php /usr/share/zabbix/conf/
  85. rm -fr /tmp/zabbix*
  86. systemctl reload nginx
  87. else
  88. ynh_print_info "Nothing to update !"
  89. fi