Repository navigation
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·69 lines (67 loc) · 2.59 KB
/
Copy pathstart.sh
File metadata and controls
executable file
·69 lines (67 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
# Start LoopForge from the published GHCR image pinned in compose.yaml
# (default), or build this checkout for development.
#
# Usage:
# ./start.sh install/start in the background (same as -d)
# ./start.sh -d install/start in the background
# ./start.sh logs follow platform logs
# ./start.sh stop stop containers, keep them and their data
# ./start.sh down remove containers, keep data volumes
# ./start.sh restart restart the platform container
# ./start.sh pull refresh images and recreate changed containers
# ./start.sh dev build this checkout (compose.dev.yaml) and start it
# ./start.sh release switch a source-built installation back to GHCR
# MIRROR=ghcr.nju.edu.cn ./start.sh
# pull ghcr.io images from that host and tag them back
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
source scripts/docker-access.sh
source scripts/ghcr-mirror.sh
compose() {
[[ -f .env ]] || docker_access_fail 'Not installed yet. Run ./start.sh first.'
select_docker_access || docker_access_fail 'Docker is not running, or this user cannot access it.'
docker_access compose --profile platform "$@"
}
cmd="${1:--d}"
shift || true
case "$cmd" in
up|-d|detach) bash scripts/install.sh ;;
dev) LOOPFORGE_BUILD_FROM_SOURCE=1 bash scripts/install.sh ;;
release)
[[ -f .env ]] && python3 - <<'PY'
import pathlib,re
p=pathlib.Path('.env')
p.write_text(re.sub(r'(?m)^COMPOSE_FILE=.*\n?','',p.read_text()))
PY
COMPOSE_FILE=compose.yaml bash scripts/install.sh
;;
pull)
# An empty MIRROR keeps the original refresh. A registry host pulls the pinned
# ghcr.io tag from that host and tags it back before MySQL is refreshed.
if [[ -n "${MIRROR:-}" ]]; then
[[ -f .env ]] || docker_access_fail 'Not installed yet. Run ./start.sh first.'
select_docker_access || docker_access_fail 'Docker is not running, or this user cannot access it.'
fi
if mirror_published_ghcr always; then
compose pull --policy always mysql
else
compose pull --ignore-buildable --policy always
fi
compose up -d --no-build --wait --wait-timeout 180
;;
logs) compose logs -f "${@:-platform}" ;;
stop) compose stop ;;
down) compose down --remove-orphans ;;
restart) compose restart platform ;;
build)
echo 'The default start uses the published GHCR image (no local build).' >&2
echo 'For a source build: ./start.sh dev' >&2
exit 1
;;
*)
echo "unknown: $cmd" >&2
echo 'usage: ./start.sh [-d|logs|stop|down|restart|pull|dev|release]' >&2
exit 1
;;
esac