install 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. popd
  46. #=================================================
  47. # SETUP SYSTEMD
  48. #=================================================
  49. ynh_script_progression --message="Configuring a systemd service..." --weight=1
  50. env_path="$PATH"
  51. # Create a dedicated systemd config
  52. ynh_add_systemd_config
  53. #=================================================
  54. # INTEGRATE SERVICE IN YUNOHOST
  55. #=================================================
  56. ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
  57. yunohost service add $app --description="Customizable browser's home page" --log="/var/log/$app/$app.log"
  58. #=================================================
  59. # START SYSTEMD SERVICE
  60. #=================================================
  61. ynh_script_progression --message="Starting a systemd service..." --weight=1
  62. # Start a systemd service
  63. ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
  64. #=================================================
  65. # END OF SCRIPT
  66. #=================================================
  67. ynh_script_progression --message="Installation of $app completed" --last