upgrade 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. # MANAGE SCRIPT FAILURE
  11. #=================================================
  12. # Exit if an error occurs during the execution of the script
  13. ynh_abort_if_errors
  14. #=================================================
  15. # LOAD SETTINGS
  16. #=================================================
  17. app=$YNH_APP_INSTANCE_NAME
  18. final_path=$(ynh_app_setting_get $app final_path)
  19. frequency=$(ynh_app_setting_get $app frequency)
  20. #=================================================
  21. # STANDARD UPGRADE STEPS
  22. #=================================================
  23. # DOWNLOAD, CHECK AND UNPACK SOURCE
  24. #=================================================
  25. # Download, check integrity, uncompress and patch the source from app.src
  26. ynh_setup_source "$final_path"
  27. #=================================================
  28. # SPECIFIC UPGRADE
  29. #=================================================
  30. # UPDATE THE CRON FILE
  31. #=================================================
  32. # Verify the checksum and backup the file if it's different
  33. ynh_backup_if_checksum_is_different "/etc/cron.d/$app"
  34. cp ../conf/cron /etc/cron.d/$app
  35. ynh_replace_string "__FINALPATH__" "$final_path" /etc/cron.d/$app
  36. ynh_replace_string "__APP__" "$app" /etc/cron.d/$app
  37. if [ "$frequency" = "Daily" ]; then
  38. cron_freq="0 2 * * *"
  39. elif [ "$frequency" = "Each 3 days" ]; then
  40. cron_freq="0 2 */3 * *"
  41. elif [ "$frequency" = "Weekly" ]; then
  42. cron_freq="0 2 * * 0"
  43. elif [ "$frequency" = "Biweekly" ]; then
  44. cron_freq="0 2 * * 0/2"
  45. else # Monthly
  46. cron_freq="0 2 1 * *"
  47. fi
  48. ynh_replace_string "__FREQUENCY__" "$cron_freq" /etc/cron.d/$app
  49. # Recalculate and store the config file checksum into the app settings
  50. ynh_store_file_checksum "/etc/cron.d/$app"
  51. #=================================================
  52. # SETUP LOGROTATE
  53. #=================================================
  54. # Use logrotate to manage app-specific logfile(s)
  55. ynh_use_logrotate
  56. #=================================================
  57. # GENERIC FINALIZATION
  58. #=================================================
  59. # SECURE FILES AND DIRECTORIES
  60. #=================================================
  61. # Set right permissions for curl installation
  62. chown -R root: $final_path