upgrade 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. #=================================================
  3. # IMPORT GENERIC HELPERS
  4. #=================================================
  5. source _common.sh
  6. source /usr/share/yunohost/helpers
  7. #=================================================
  8. # ENSURE DOWNWARD COMPATIBILITY
  9. #=================================================
  10. ynh_script_progression "Ensuring downward compatibility..."
  11. _fix_frequencies
  12. _set_frequencies
  13. # If encrypt doesn't exist, create it
  14. if [ -z "${encrypt:-}" ]; then
  15. encrypt="$(grep "^encrypt=" "$install_dir/Backup_list.conf" | cut -d= -f2)"
  16. if [ "$encrypt" = true ]; then
  17. encrypt=1
  18. else
  19. encrypt=0
  20. fi
  21. ynh_app_setting_set --key="encrypt" --value="$encrypt"
  22. fi
  23. # If core_backup doesn't exist, create it
  24. ynh_app_setting_set_default --key=core_backup --value="$(grep "^ynh_core_backup=" "$install_dir/Backup_list.conf" | cut -d= -f2)"
  25. # If apps_backup doesn't exist, create it
  26. ynh_app_setting_set_default --key=apps_backup --value="$(grep --count --max-count=1 "^ynh_app_backup=" "$install_dir/Backup_list.conf")"
  27. # If overwrite_cron doesn't exist, create it
  28. ynh_app_setting_set_default --key=overwrite_cron --value=1
  29. # If admin_mail_html doesn't exist, create it
  30. ynh_app_setting_set_default --key=admin_mail_html --value=1
  31. #=================================================
  32. # DOWNLOAD, CHECK AND UNPACK SOURCE
  33. #=================================================
  34. ynh_script_progression "Upgrading source files..."
  35. # Download, check integrity, uncompress and patch the source from app.src
  36. ynh_setup_source --dest_dir="$install_dir" --full_replace --keep="passkey Backup_list.conf"
  37. chown -R "root:root" "$install_dir"
  38. #=================================================
  39. # UPDATE A CONFIG FILE
  40. #=================================================
  41. ynh_script_progression "Updating $app's configuration files..."
  42. #=================================================
  43. # REAPPLY SYSTEM CONFIGURATIONS
  44. #=================================================
  45. ynh_script_progression "Upgrading system configurations related to $app..."
  46. # Use logrotate to manage app-specific logfile(s)
  47. ynh_config_add_logrotate
  48. if (( overwrite_cron == 1 )); then
  49. # Add Cron configuration file
  50. ynh_config_add --template="archivist.cron" --destination="/etc/cron.d/$app"
  51. fi
  52. #=================================================
  53. # END OF SCRIPT
  54. #=================================================
  55. ynh_script_progression "Upgrade of $app completed"