upgrade 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/bin/bash
  2. #=================================================
  3. # GENERIC START
  4. #=================================================
  5. # IMPORT GENERIC HELPERS
  6. #=================================================
  7. source _common.sh
  8. source /usr/share/yunohost/helpers
  9. secret=$(ynh_string_random --length=24)
  10. timezone=$(cat /etc/timezone)
  11. #=================================================
  12. # CHECK VERSION
  13. #=================================================
  14. upgrade_type=$(ynh_check_app_version_changed)
  15. #=================================================
  16. # STANDARD UPGRADE STEPS
  17. #=================================================
  18. # STOP SYSTEMD SERVICE
  19. #=================================================
  20. ynh_script_progression --message="Stopping a systemd service..." --weight=1
  21. ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
  22. #=================================================
  23. # DOWNLOAD, CHECK AND UNPACK SOURCE
  24. #=================================================
  25. if [ "$upgrade_type" == "UPGRADE_APP" ]
  26. then
  27. ynh_script_progression --message="Upgrading source files..." --weight=1
  28. # Download, check integrity, uncompress and patch the source from app.src
  29. ynh_setup_source --dest_dir="$install_dir" --keep=".env"
  30. fi
  31. chmod -R o-rwx "$install_dir"
  32. chown -R $app:www-data "$install_dir"
  33. #=================================================
  34. # UPGRADE DEPENDENCIES
  35. #=================================================
  36. ynh_script_progression --message="Upgrading dependencies..." --weight=1
  37. # Install Nodejs
  38. ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
  39. #=================================================
  40. # NGINX CONFIGURATION
  41. #=================================================
  42. ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
  43. # Create a dedicated NGINX config
  44. ynh_add_nginx_config
  45. env_path="$PATH"
  46. # Create a dedicated systemd config
  47. ynh_add_systemd_config
  48. yunohost service add $app --description="Customizable browser's home page" --log="/var/log/$app/$app.log"
  49. #=================================================
  50. # ADD A CONFIGURATION
  51. #=================================================
  52. ynh_script_progression --message="Adding a configuration file..." --weight=1
  53. ynh_add_config --template=".env" --destination="$install_dir/.env"
  54. chmod 400 "$install_dir/.env"
  55. chown $app:$app "$install_dir/.env"
  56. #=================================================
  57. # INSTALL HOMARR
  58. #=================================================
  59. ynh_script_progression --message="Building the app..." --weight=20
  60. pushd $install_dir
  61. ynh_use_nodejs
  62. ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn install
  63. ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH NODE_ENV=production yarn build
  64. ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn db:migrate
  65. popd
  66. #=================================================
  67. # START SYSTEMD SERVICE
  68. #=================================================
  69. ynh_script_progression --message="Starting a systemd service..." --weight=1
  70. ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
  71. #=================================================
  72. # END OF SCRIPT
  73. #=================================================
  74. ynh_script_progression --message="Upgrade of $app completed" --last