-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbuild.sh
executable file
·60 lines (54 loc) · 1.36 KB
/
build.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
#!/bin/bash
GS_PATH=$(echo $(realpath "$(dirname "$0")"))
builder() {
mkdir -p $GS_PATH/binary
sudo docker run --rm -v $GS_PATH/api:/api -v $GS_PATH/binary:/binary nativeplanet/groundseg-builder:3.10.9
}
standard_build() {
builder
echo "Standard build complete. GroundSeg binary in $GS_PATH/binary"
}
clean_docker() {
echo "Wiping all docker containers, volumes and images."
sudo docker stop $(sudo docker ps -aq)
sudo docker rm -f $(sudo docker ps -aq)
sudo docker volume prune -f
sudo docker rmi -f $(sudo docker images -q)
sudo rm -r /opt/nativeplanet/groundseg/*
echo "Starting build"
builder
echo "Clean build complete. GroundSeg binary in $GS_PATH/binary"
}
# Check if --clean is passed
clean_flag=false
for flag in "$@"
do
if [ "$flag" == "--clean" ]; then
clean_flag=true
fi
done
if ! $clean_flag; then
standard_build
exit 1
fi
# Loop through all the arguments passed
for arg in "$@"
do
case $arg in
"--clean")
clean_docker
;;
"--prod")
sudo mkdir -p /opt/nativeplanet/groundseg
sudo cp $GS_PATH/binary/groundseg /opt/nativeplanet/groundseg/groundseg
echo "Copied GroundSeg binary to /opt/nativeplanet/groundseg/groundseg"
;;
"--start")
echo "Start WIP"
;;
*)
# If an invalid argument is passed, exit the script
echo "Invalid argument: $arg"
;;
esac
done