diff --git a/scripts/setup-ai.sh b/scripts/setup-ai.sh index 23e9a6c..b6f85be 100755 --- a/scripts/setup-ai.sh +++ b/scripts/setup-ai.sh @@ -14,17 +14,6 @@ if [[ -z "$PI_VERSION" || "$PI_VERSION" == "n" ]]; then exit; fi -echo "Adding environment variables. For more information, visist raspi.vintagecoding.net#env-vars"; -echo "export OLLAMA_BASE_URL=http://localhost:$OLLAMA_PORT;"; >> $HOME/.bashrc; - -read -p "Do you want to require login to your AI? (n/Y)" REQUIRE_LOGIN -REQUIRE_LOGIN=$(echo "$REQUIRE_LOGIN" | tr '[:upper:]' '[:lower:]') -if [[ -z "$REQUIRE_LOGIN" || "$REQUIRE_LOGIN" == "n" ]]; then - export WEBUI_AUTH=False >> $HOME/.bashrc; -fi - -source $HOME/.bashrc - echo "Running `python -m venv open-webui-env`. This creates a Python virtual environment, where"; echo "we can install applications in an isolated manner from the rest of our Operating System (OS)."; python -m venv open-webui-env; @@ -41,7 +30,7 @@ server_name localhost; location / { proxy_pass http://localhost:$OPEN_WEBUI_PORT/; proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; + proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; @@ -74,6 +63,9 @@ Type=simple Restart=always RestartSec=1 User=$(whoami) +Environment=WEBUI_AUTH=True +Environment=WEBUI_BASE_URL=https://TMP_URL +Environment=OLLAMA_BASE_URL=http://localhost:11434 WorkingDirectory=$HOME ExecStartPre=/bin/bash -c "source /home/$(whoami)/open-webui-env/bin/activate" ExecStart=/home/$(whoami)/open-webui/open-webui-env/bin/open-webui serve --port $OLLAMA_PORT @@ -81,4 +73,10 @@ ExecStart=/home/$(whoami)/open-webui/open-webui-env/bin/open-webui serve --port [Install] WantedBy=multi-user.target" | sudo tee /etc/systemd/system/open-webui.service; -sudo systemctl daemon-reload && sudo systemctl enable open-webui.service; +read -p "Do you want to require login to your AI? (n/Y)" REQUIRE_LOGIN +REQUIRE_LOGIN=$(echo "$REQUIRE_LOGIN" | tr '[:upper:]' '[:lower:]') +if [[ -z "$REQUIRE_LOGIN" || "$REQUIRE_LOGIN" == "n" ]]; then + sudo sed -i -e 's/WEBUI_AUTH=True/WEBUI_AUTH=False/' /etc/systemd/system/open-webui.service; +fi + +sudo systemctl daemon-reload && sudo systemctl enable open-webui.service && sudo systemctl start open-webui.service; diff --git a/scripts/setup-cloudflared.sh b/scripts/setup-cloudflared.sh index bb0f03f..0c7b4b1 100755 --- a/scripts/setup-cloudflared.sh +++ b/scripts/setup-cloudflared.sh @@ -44,26 +44,22 @@ cloudflared tunnel route dns $TUNNEL_ID raspi.$DOMAIN; cloudflared tunnel route dns $TUNNEL_ID media.$DOMAIN; cloudflared tunnel route dns $TUNNEL_ID ai.$DOMAIN; -ACTUAL_USER=$(whoami) - echo "[Unit] Description=Cloudflare Tunnel Daemon After=network.target [Service] Type=simple -User=$ACTUAL_USER +User=$(whoami) ExecStart=/usr/bin/cloudflared tunnel run raspi Restart=always [Install] WantedBy=multi-user.target" | sudo tee /etc/systemd/system/cloudflared.service; -sudo systemctl enable cloudflared.service; - -source ~/.bashrc; +sudo systemctl daemon-reload && sudo systemctl enable cloudflared.service && sudo systemctl start cloudflared.service; sudo sed -i -e 's/server_name localhost/servername ai.$DOMAIN/' /etc/nginx/sites-available/open-webui; +sudo sed -i -e 's/WEBUI_BASE_URL=localhost/WEBUI_BASE_URL=https://ai.$DOMAIN/' /etc/systemd/system/open-webui.service; -export WEBUI_BASE_URL=ai.$DOMAIN >> $HOME/.bashrc; -sudo systemctl restart open-webui.service; +sudo systemctl daemon-reload && sudo systemctl restart open-webui.service; diff --git a/scripts/setup-jellyfin.sh b/scripts/setup-jellyfin.sh index 47beb19..666a5ad 100755 --- a/scripts/setup-jellyfin.sh +++ b/scripts/setup-jellyfin.sh @@ -1,6 +1,6 @@ #!/bin/bash -$JELLYFIN_PORT=5091; +JELLYFIN_PORT=5091; # Get the official image of Jellyfin software. echo "Running `podman pull ghcr.io/jellyfin/jellyfin`"; @@ -58,6 +58,6 @@ ExecStart=/usr/bin/podman start myjellyfin [Install] WantedBy=multi-user.target" | sudo tee /etc/systemd/system/jellyfin.service; -sudo systemctl daemon-reload && sudo systemctl enable jellyfin.service; +sudo systemctl daemon-reload && sudo systemctl enable jellyfin.service && sudo systemctl start jellyfin.service; echo "For now, please visit jellyfin.org/docs for information about setting up Jellyfin. We'll have a more comprehensive guide soon."; diff --git a/scripts/setup-manual.sh b/scripts/setup-manual.sh index a25b202..8bc8cae 100755 --- a/scripts/setup-manual.sh +++ b/scripts/setup-manual.sh @@ -1,6 +1,6 @@ #!/bin/bash -$MANUAL_PORT=5090; +MANUAL_PORT=5090; echo "Creating a SystemD service file. These are commands (applications) that you can set to start as soon as you turn on the Pi."; echo "This file is located at `/etc/systemd/system/manual.service`."; @@ -23,7 +23,7 @@ ExecStart=/usr/bin/python3 -m http.server $MANUAL_PORT [Install] WantedBy=multi-user.target" | sudo tee /etc/systemd/system/manual.service; -sudo systemctl daemon-reload && sudo systemctl enable manual.service; +sudo systemctl daemon-reload && sudo systemctl enable manual.service && sudo systemctl start manual.service; echo "For now, this uses the command `python -m http.server 5090` to serve the man/pages on port 5090."; echo "For more information, see raspi.vintagecoding.net#web-servers";