chore: import deployable mai-bot source tree
This commit is contained in:
79
deploy/server-maibot/activate-release.sh
Normal file
79
deploy/server-maibot/activate-release.sh
Normal file
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
release_dir="${1:?usage: activate-release.sh <release-dir>}"
|
||||
runtime_root="${MAIBOT_RUNTIME_ROOT:-/root/maibot-offline}"
|
||||
|
||||
case "$runtime_root" in
|
||||
/root/maibot-offline|/root/maibot-offline/*) ;;
|
||||
*)
|
||||
echo "runtime root must stay under /root/maibot-offline" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ! -d "$release_dir" ]; then
|
||||
echo "release dir not found: $release_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p \
|
||||
"$runtime_root" \
|
||||
"$runtime_root/data/MaiMBot" \
|
||||
"$runtime_root/data/MaiMBot/emoji" \
|
||||
"$runtime_root/data/MaiMBot/plugins" \
|
||||
"$runtime_root/data/MaiMBot/logs" \
|
||||
"$runtime_root/data/qq" \
|
||||
"$runtime_root/depends-data" \
|
||||
"$runtime_root/docker-config/mmc" \
|
||||
"$runtime_root/docker-config/napcat"
|
||||
|
||||
python3 - "$release_dir" "$runtime_root" <<'PY'
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
src = Path(sys.argv[1]).resolve()
|
||||
dst = Path(sys.argv[2]).resolve()
|
||||
|
||||
skip_names = {
|
||||
".git",
|
||||
".gitea",
|
||||
".github",
|
||||
".venv",
|
||||
"data",
|
||||
"docker-config",
|
||||
"depends-data",
|
||||
"logs",
|
||||
"plugins",
|
||||
"acme",
|
||||
"backups",
|
||||
"bin",
|
||||
"_staging",
|
||||
}
|
||||
skip_suffixes = {".pem", ".key", ".tar", ".tgz", ".zip"}
|
||||
|
||||
for item in src.iterdir():
|
||||
if item.name in skip_names or item.suffix in skip_suffixes:
|
||||
continue
|
||||
|
||||
target = dst / item.name
|
||||
if target.exists():
|
||||
if target.is_dir() and not target.is_symlink():
|
||||
shutil.rmtree(target)
|
||||
else:
|
||||
target.unlink()
|
||||
|
||||
if item.is_dir():
|
||||
shutil.copytree(
|
||||
item,
|
||||
target,
|
||||
ignore=shutil.ignore_patterns("__pycache__", "*.pyc", "*.pyo"),
|
||||
)
|
||||
else:
|
||||
shutil.copy2(item, target)
|
||||
PY
|
||||
|
||||
cd "$runtime_root"
|
||||
docker build -f deploy/server-maibot/Dockerfile.offline -t maibot-offline:latest .
|
||||
docker compose -f deploy/server-maibot/docker-compose.server.yml up -d
|
||||
Reference in New Issue
Block a user