install 3.1 KB

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