upgrade 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 --message="Ensuring downward compatibility..."
  11. _set_frequencies
  12. # If encrypt doesn't exist, create it
  13. if [ -z "${encrypt:-}" ]; then
  14. encrypt="$(grep "^encrypt=" "$install_dir/Backup_list.conf" | cut -d= -f2)"
  15. if [ "$encrypt" = true ]; then
  16. encrypt=1
  17. else
  18. encrypt=0
  19. fi
  20. ynh_app_setting_set --app="$app" --key="encrypt" --value="$encrypt"
  21. fi
  22. # If core_backup doesn't exist, create it
  23. if [ -z "${core_backup:-}" ]; then
  24. core_backup="$(grep "^ynh_core_backup=" "$install_dir/Backup_list.conf" | cut -d= -f2)"
  25. ynh_app_setting_set --app="$app" --key="core_backup" --value="$core_backup"
  26. fi
  27. # If apps_backup doesn't exist, create it
  28. if [ -z "${apps_backup:-}" ]; then
  29. apps_backup="$(grep --count --max-count=1 "^ynh_app_backup=" "$install_dir/Backup_list.conf")"
  30. ynh_app_setting_set --app="$app" --key="apps_backup" --value="$apps_backup"
  31. fi
  32. # If overwrite_cron doesn't exist, create it
  33. if [ -z "${overwrite_cron:-}" ]; then
  34. overwrite_cron=1
  35. ynh_app_setting_set --app="$app" --key="overwrite_cron" --value="$overwrite_cron"
  36. fi
  37. # If admin_mail_html doesn't exist, create it
  38. if [ -z "${admin_mail_html:-}" ]; then
  39. admin_mail_html=1
  40. ynh_app_setting_set --app="$app" --key="admin_mail_html" --value="$admin_mail_html"
  41. fi
  42. #=================================================
  43. # DOWNLOAD, CHECK AND UNPACK SOURCE
  44. #=================================================
  45. ynh_script_progression --message="Upgrading source files..." --weight=2
  46. # Download, check integrity, uncompress and patch the source from app.src
  47. ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="passkey Backup_list.conf"
  48. chown -R "root:root" "$install_dir"
  49. #=================================================
  50. # UPDATE A CONFIG FILE
  51. #=================================================
  52. ynh_script_progression --message="Updating $app's configuration files..." --weight=1
  53. #=================================================
  54. # REAPPLY SYSTEM CONFIGURATIONS
  55. #=================================================
  56. ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
  57. # Use logrotate to manage app-specific logfile(s)
  58. ynh_use_logrotate --non-append
  59. if (( overwrite_cron == 1 )); then
  60. # Add Cron configuration file
  61. ynh_add_config --template="archivist.cron" --destination="/etc/cron.d/$app"
  62. fi
  63. #=================================================
  64. # END OF SCRIPT
  65. #=================================================
  66. ynh_script_progression --message="Upgrade of $app completed" --last