-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.sh
71 lines (57 loc) · 1.58 KB
/
manage.sh
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
70
71
#!/usr/bin/env bash
start() {
echo "Starting up the Sourcegraph VM..."
[[ $(podman machine inspect "${sg_machine}" | jq -r '.[0].State') = running ]] || {
podman machine start "${sg_machine}"
}
[[ $(podman machine inspect "${sg_machine}" | jq -r '.[0].State') = running ]] || {
echo "failed to start a podman machine" 1>&2
return 1
}
echo "OK"
socket=$(podman machine inspect "${sg_machine}" | jq -r '.[0].ConnectionInfo.PodmanSocket.Path')
export CONTAINER_HOST=unix://${socket}
echo "Launching Sourcegraph..."
podman-compose --project-name="${sg_machine}" up -d || {
echo "failed to start Sourcegraph" 1>&2
return 1
}
echo "OK"
echo "Waiting for Sourcegraph to be ready..."
sleep 3
echo "OK"
echo "Launching Sourcegraph..."
open http://localhost
}
stop() {
echo "Bringing down Sourcegraph..."
podman-compose --project-name="${sg_machine}" down
echo "OK"
echo "Stopping the Sourcegraph VM"
podman machine stop "${sg_machine}"
echo "OK"
}
sg_machine="sourcegraph-admin"
pushd ~/.sourcegraph/deploy-sourcegraph-docker/docker-compose || {
echo "cannot find SG install directory" 1>&2
exit 1
}
podman machine inspect "${sg_machine}" &>/dev/null || {
echo "failed to provision a VM for Sourcegraph" 1>&2
exit 1
}
case "${1}" in
start)
start || exit 1
;;
stop)
stop || exit 1
;;
restart)
stop || exit 1
start || exit 1
;;
*)
echo "${0} start|stop|restart" 1>&2
exit 1
esac