forked from goinfinite/os
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev-build.sh
More file actions
80 lines (69 loc) · 1.83 KB
/
dev-build.sh
File metadata and controls
80 lines (69 loc) · 1.83 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
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# Define the execution arguments.
ports=(-p 1618:1618)
case ${1} in
http)
sudo sysctl net.ipv4.ip_unprivileged_port_start=80
ports+=(-p 80:80 -p 443:443)
;;
http-unpriv)
ports+=(-p 8080:80 -p 8443:443)
;;
ols)
ports+=(-p 7080:7080)
;;
ssh)
ports+=(-p 2222:22)
;;
no-cache)
podman image prune -a
podman rmi localhost/os -f
;;
esac
echo "=> Building the container..."
make build
podman build -t os:latest .
# TODO: Re-add --env 'DEV_MODE=true' after Echo v4.13.0 release.
podman run --name os -d \
--env 'LOG_LEVEL=debug' --env 'PRIMARY_VHOST=goinfinite.local' \
--hostname=goinfinite.local --cpus=2 --memory=2g --rm \
--volume "$(pwd)/bin:/infinite/bin:Z,ro,bind,slave" \
"${ports[@]}" -it os:latest
echo "=> Waiting for the container to start..."
sleep 5
echo "=> Replacing the standard binary with the development binary..."
podman exec os /bin/bash -c 'rm -f os && ln -s bin/os os && supervisorctl restart os-api'
echo "=> Creating a development account..."
podman exec os /bin/bash -c 'os account create -u dev -p 123456 --is-super-admin false'
if [[ ${1} == "ssh" ]]; then
echo "=> Installing OpenSSH..."
podman exec os /bin/bash -c 'os services create-installable -n openssh'
fi
echo
echo "<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>"
echo
echo "=> Starting the development build..."
echo "Any changes to the code will trigger a rebuild automatically."
echo "Ignore the 'InfiniteOsMustBeRunAsRoot' message or enable DEV_MODE."
echo
echo "<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>"
echo
sleep 3
stopDevBuild() {
kill $airPid
kill $podmanPid
podman stop os &>/dev/null
podman rm os &>/dev/null
echo
echo "=> Development build stopped."
echo
clear
exit
}
trap stopDevBuild SIGINT
air &
airPid=$!
podman attach os &
podmanPid=$!
wait $airPid
wait $podmanPid