install 2.7 KB

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