diff --git a/ct/tubearchivist.sh b/ct/tubearchivist.sh index 2ab5b180f..885797a69 100644 --- a/ct/tubearchivist.sh +++ b/ct/tubearchivist.sh @@ -71,6 +71,41 @@ EOF restore_backup + if grep -q '^TA_BACKEND_PORT=' /opt/tubearchivist/.env 2>/dev/null; then + msg_info "Migrating to v0.6.0 (dropping Nginx)" + systemctl disable -q --now nginx + $STD apt autoremove --purge -y nginx + sed -i 's/^TA_BACKEND_PORT=.*/TA_PORT=8000/' /opt/tubearchivist/.env + cat <<'RUNEOF' >/opt/tubearchivist/backend/run.sh +#!/bin/bash +set -e +cd /opt/tubearchivist/backend +set -a +source /opt/tubearchivist/.env +set +a +PYTHON=/opt/tubearchivist/.venv/bin/python + +echo "Waiting for ElasticSearch..." +for i in $(seq 1 30); do + if curl -sf http://localhost:9200/_cluster/health >/dev/null 2>&1; then + break + fi + sleep 2 +done + +$PYTHON manage.py ta_stop_on_error +$PYTHON manage.py migrate +$PYTHON manage.py collectstatic --noinput -c +$PYTHON manage.py ta_envcheck +$PYTHON manage.py ta_connection +$PYTHON manage.py ta_startup + +exec $PYTHON backend_start.py +RUNEOF + chmod +x /opt/tubearchivist/backend/run.sh + msg_ok "Migrated to v0.6.0 (dropping Nginx)" + fi + msg_info "Rebuilding Tube Archivist" cd /opt/tubearchivist/frontend $STD npm install @@ -113,7 +148,6 @@ EOF msg_info "Starting Services" systemctl start bgutil-provider tubearchivist tubearchivist-celery tubearchivist-beat - systemctl reload nginx msg_ok "Started Services" msg_ok "Updated successfully!" fi diff --git a/install/tubearchivist-install.sh b/install/tubearchivist-install.sh index a5ec3b0f3..c6f8f4c1d 100644 --- a/install/tubearchivist-install.sh +++ b/install/tubearchivist-install.sh @@ -17,7 +17,6 @@ msg_info "Installing Dependencies" $STD apt install -y \ build-essential \ git \ - nginx \ redis-server \ atomicparsley \ python3-dev \ @@ -107,7 +106,7 @@ cat </opt/tubearchivist/.env TA_HOST=http://${LOCAL_IP}:8000 TA_USERNAME=admin TA_PASSWORD=${TA_PASSWORD} -TA_BACKEND_PORT=8080 +TA_PORT=8000 TA_APP_DIR=/opt/tubearchivist/backend TA_CACHE_DIR=/cache TA_MEDIA_DIR=/youtube @@ -133,92 +132,6 @@ msg_info "Installing yt-dlp Nightly" $STD uv pip install --python /opt/tubearchivist/.venv/bin/python -U --prerelease allow "yt-dlp[default]" msg_ok "Installed yt-dlp Nightly" -msg_info "Configuring Nginx" -sed -i 's/^user www-data;$/user root;/' /etc/nginx/nginx.conf -cat <<'EOF' >/etc/nginx/sites-available/default -server { - listen 8000; - - location = /_auth { - internal; - proxy_pass http://localhost:8080/api/ping/; - proxy_pass_request_body off; - proxy_set_header Content-Length ""; - proxy_set_header Host $http_host; - proxy_set_header Cookie $http_cookie; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } - - location /cache/videos/ { - auth_request /_auth; - alias /cache/videos/; - } - - location /cache/channels/ { - auth_request /_auth; - alias /cache/channels/; - } - - location /cache/playlists/ { - auth_request /_auth; - alias /cache/playlists/; - } - - location /media/ { - auth_request /_auth; - alias /youtube/; - types { - text/vtt vtt; - } - } - - location /youtube/ { - auth_request /_auth; - alias /youtube/; - types { - video/mp4 mp4; - } - } - - location /api { - include proxy_params; - proxy_pass http://localhost:8080; - } - - location /admin { - include proxy_params; - proxy_pass http://localhost:8080; - } - - location /static/ { - alias /opt/tubearchivist/backend/staticfiles/; - } - - root /opt/tubearchivist/backend/static; - index index.html; - - location ~* ^/(?!static/|cache/).*\.(?:css|js|png|jpg|jpeg|gif|ico|svg|woff2?)$ { - try_files $uri $uri/ /index.html =404; - } - - location = /index.html { - add_header Cache-Control "no-store, no-cache, must-revalidate"; - add_header Pragma "no-cache"; - expires 0; - } - - location / { - add_header Cache-Control "no-store, no-cache, must-revalidate"; - add_header Pragma "no-cache"; - expires 0; - try_files $uri $uri/ /index.html =404; - } -} -EOF -systemctl enable -q nginx -systemctl restart nginx -msg_ok "Configured Nginx" - msg_info "Creating Services" cat <<'RUNEOF' >/opt/tubearchivist/backend/run.sh #!/bin/bash @@ -237,6 +150,7 @@ for i in $(seq 1 30); do sleep 2 done +$PYTHON manage.py ta_stop_on_error $PYTHON manage.py migrate $PYTHON manage.py collectstatic --noinput -c $PYTHON manage.py ta_envcheck