upgrade 3.2 KB

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