init biliup-next

This commit is contained in:
theshy
2026-04-01 00:44:58 +08:00
commit d0cf1fd0df
127 changed files with 15582 additions and 0 deletions

49
install-systemd.sh Executable file
View File

@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -euo pipefail
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SYSTEMD_DIR="$PROJECT_DIR/systemd"
RENDER_DIR="$SYSTEMD_DIR/rendered"
USER_NAME="${BILIUP_NEXT_USER:-$(id -un)}"
GROUP_NAME="${BILIUP_NEXT_GROUP:-$(id -gn)}"
DEFAULT_PYTHON="$PROJECT_DIR/../.venv/bin/python"
if [[ -x "$DEFAULT_PYTHON" ]]; then
PYTHON_BIN="${BILIUP_NEXT_PYTHON:-$(readlink -f "$DEFAULT_PYTHON")}"
else
PYTHON_BIN="${BILIUP_NEXT_PYTHON:-$(command -v python3)}"
fi
render_unit() {
local template="$1"
local output="$2"
sed \
-e "s|__PROJECT_DIR__|$PROJECT_DIR|g" \
-e "s|__USER__|$USER_NAME|g" \
-e "s|__GROUP__|$GROUP_NAME|g" \
-e "s|__PYTHON_BIN__|$PYTHON_BIN|g" \
"$template" > "$output"
}
mkdir -p "$RENDER_DIR"
render_unit \
"$SYSTEMD_DIR/biliup-next-worker.service.template" \
"$RENDER_DIR/biliup-next-worker.service"
render_unit \
"$SYSTEMD_DIR/biliup-next-api.service.template" \
"$RENDER_DIR/biliup-next-api.service"
sudo install -m 0644 "$RENDER_DIR/biliup-next-worker.service" /etc/systemd/system/biliup-next-worker.service
sudo install -m 0644 "$RENDER_DIR/biliup-next-api.service" /etc/systemd/system/biliup-next-api.service
sudo systemctl daemon-reload
sudo systemctl enable --now biliup-next-worker.service
sudo systemctl enable --now biliup-next-api.service
echo "Installed:"
echo " /etc/systemd/system/biliup-next-worker.service"
echo " /etc/systemd/system/biliup-next-api.service"
echo "User: $USER_NAME"
echo "Group: $GROUP_NAME"
echo "Python: $PYTHON_BIN"