upgrade 2.9 KB

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