install 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. # APP INITIAL CONFIGURATION
  27. #=================================================
  28. ynh_script_progression --message="Adding $app's configuration files..." --weight=1
  29. # Create a dedicated NGINX config
  30. ynh_add_nginx_config
  31. # Create a dedicated systemd config
  32. ynh_add_systemd_config
  33. yunohost service add $app --description="Customizable browser's home page" --log="/var/log/$app/$app.log"
  34. #=================================================
  35. # ADD A CONFIGURATION
  36. #=================================================
  37. ynh_script_progression --message="Adding a configuration file..." --weight=1
  38. ynh_add_config --template=".env" --destination="$install_dir/.env"
  39. chmod 400 "$install_dir/.env"
  40. chown $app:$app "$install_dir/.env"
  41. #=================================================
  42. # INSTALL HOMARR
  43. #=================================================
  44. ynh_script_progression --message="Building the app..." --weight=20
  45. pushd $install_dir
  46. ynh_use_nodejs
  47. ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn install
  48. ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH NODE_ENV=production yarn build
  49. ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn db:migrate
  50. popd
  51. #=================================================
  52. # START SYSTEMD SERVICE
  53. #=================================================
  54. ynh_script_progression --message="Starting a systemd service..." --weight=1
  55. # Start a systemd service
  56. ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
  57. #=================================================
  58. # END OF SCRIPT
  59. #=================================================
  60. ynh_script_progression --message="Installation of $app completed" --last