upgrade 4.1 KB

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