upgrade 3.0 KB

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