install 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/bash
  2. #=================================================
  3. # IMPORT GENERIC HELPERS
  4. #=================================================
  5. source _common.sh
  6. source /usr/share/yunohost/helpers
  7. mail=$(ynh_user_get_info --username=$admin --key=mail)
  8. #=================================================
  9. # INITIALIZE AND STORE SETTINGS
  10. #=================================================
  11. #=================================================
  12. # DOWNLOAD, CHECK AND UNPACK SOURCE
  13. #=================================================
  14. ynh_script_progression "Setting up source files..."
  15. ynh_setup_source --dest_dir="$install_dir"
  16. chown -R "$app:www-data" "$install_dir"
  17. pushd $install_dir
  18. ynh_exec_as_app python3 -m venv venv
  19. echo "source $install_dir/venv/bin/activate" >> $install_dir/.bashrc
  20. source "$install_dir/venv/bin/activate"
  21. ynh_exec_as_app pip install open-webui
  22. deactivate
  23. popd
  24. chown -R "$app:www-data" "$install_dir"
  25. #=================================================
  26. # APP INITIAL CONFIGURATION
  27. #=================================================
  28. ynh_script_progression "Adding $app's configuration files..."
  29. ynh_config_add --template=".env" --destination="$install_dir/.env"
  30. chmod 400 "$install_dir/.env"
  31. chown "$app:$app" "$install_dir/.env"
  32. #=================================================
  33. # SYSTEM CONFIGURATION
  34. #=================================================
  35. ynh_script_progression "Adding system configurations related to $app..."
  36. ynh_config_add_nginx
  37. ynh_config_add_systemd
  38. yunohost service add "$app" --description="User-friendly AI Interface (Supports Ollama, OpenAI API, ...)" --log="/var/log/$app/$app.log"
  39. ynh_config_add_logrotate
  40. #ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
  41. #=================================================
  42. # END OF SCRIPT
  43. #=================================================
  44. ynh_script_progression "Installation of $app completed"