upgrade 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. # FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=core_backup --value="$(grep "^ynh_core_backup=" "$install_dir/Backup_list.conf" | cut -d= -f2)"
  25. if [ -z "${core_backup:-}" ]; then
  26. core_backup="$(grep "^ynh_core_backup=" "$install_dir/Backup_list.conf" | cut -d= -f2)"
  27. ynh_app_setting_set --key="core_backup" --value="$core_backup"
  28. fi
  29. # If apps_backup doesn't exist, create it
  30. # FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=apps_backup --value="$(grep --count --max-count=1 "^ynh_app_backup=" "$install_dir/Backup_list.conf")"
  31. if [ -z "${apps_backup:-}" ]; then
  32. apps_backup="$(grep --count --max-count=1 "^ynh_app_backup=" "$install_dir/Backup_list.conf")"
  33. ynh_app_setting_set --key="apps_backup" --value="$apps_backup"
  34. fi
  35. # If overwrite_cron doesn't exist, create it
  36. # FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=overwrite_cron --value=1
  37. if [ -z "${overwrite_cron:-}" ]; then
  38. overwrite_cron=1
  39. ynh_app_setting_set --key="overwrite_cron" --value="$overwrite_cron"
  40. fi
  41. # If admin_mail_html doesn't exist, create it
  42. # FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=admin_mail_html --value=1
  43. if [ -z "${admin_mail_html:-}" ]; then
  44. admin_mail_html=1
  45. ynh_app_setting_set --key="admin_mail_html" --value="$admin_mail_html"
  46. fi
  47. #=================================================
  48. # DOWNLOAD, CHECK AND UNPACK SOURCE
  49. #=================================================
  50. ynh_script_progression "Upgrading source files..."
  51. # Download, check integrity, uncompress and patch the source from app.src
  52. ynh_setup_source --dest_dir="$install_dir" --full_replace --keep="passkey Backup_list.conf"
  53. #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "root:root" "$install_dir"
  54. #=================================================
  55. # UPDATE A CONFIG FILE
  56. #=================================================
  57. ynh_script_progression "Updating $app's configuration files..."
  58. #=================================================
  59. # REAPPLY SYSTEM CONFIGURATIONS
  60. #=================================================
  61. ynh_script_progression "Upgrading system configurations related to $app..."
  62. # Use logrotate to manage app-specific logfile(s)
  63. ynh_config_add_logrotate
  64. if (( overwrite_cron == 1 )); then
  65. # Add Cron configuration file
  66. ynh_config_add --template="archivist.cron" --destination="/etc/cron.d/$app"
  67. fi
  68. #=================================================
  69. # END OF SCRIPT
  70. #=================================================
  71. ynh_script_progression "Upgrade of $app completed"