-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-gamesvr-blackmesa.sh
More file actions
executable file
·106 lines (82 loc) · 3.39 KB
/
Copy pathbuild-gamesvr-blackmesa.sh
File metadata and controls
executable file
·106 lines (82 loc) · 3.39 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
set -e;
set -u;
####################################################################################################
## Options
####################################################################################################
# Default options
option_delta_updates=false; # Only build delta layer at the base image level?
# Parse command line options
while [ "$#" -gt 0 ]
do
case "$1" in
# options
-d|--delta)
option_delta_updates=true;
;;
# unknown
*)
echo "Error: unknown option '${1}'. Exiting." >&2;
exit 12;
;;
esac
shift
done;
####################################################################################################
## Helper Functions
####################################################################################################
# Custom sigterm handler, so that interupt signals terminate the script, not just a single command.
sigterm_handler() {
echo -e "\n";
exit 1;
}
trap 'trap " " SIGINT SIGTERM SIGHUP; kill 0; wait; sigterm_handler' SIGINT SIGTERM SIGHUP;
####################################################################################################
## Build
####################################################################################################
if [ "$option_delta_updates" != 'true' ]; then
#
# Full Update
#
echo -e '\n\033[1m[Build Full Image]\033[0m';
docker build . -f linux.Dockerfile --rm -t lacledeslan/gamesvr-blackmesa:latest --no-cache --pull --build-arg BUILDNODE="$(cat /proc/sys/kernel/hostname)";
else
#
# Delta Update
#
echo -e '\n\033[1m[Grabbing and Extracting SteamCMD]\033[0m';
# to bad `--volumes-from` doesn't support path aliasing ヽ(ಠ_ಠ)ノ
docker container rm LLSteamCMD-Extractor &>/dev/null || true
docker create --name LLSteamCMD-Extractor lacledeslan/steamcmd:latest;
docker cp LLSteamCMD-Extractor:/app "$(pwd)/.steamcmd/linux";
docker container rm LLSteamCMD-Extractor;
echo -e '\n\033[1m[Building Delta Container]\033[0m'
docker pull lacledeslan/gamesvr-blackmesa:base
docker container rm LL-BLACKMESA-DELTA-CAPTURE &>/dev/null || true
docker run -it --name LL-BLACKMESA-DELTA-CAPTURE \
--mount type=bind,source="$(pwd)"/.steamcmd/linux/app/,target=/steamcmd/ \
lacledeslan/gamesvr-blackmesa \
/steamcmd/steamcmd.sh +login anonymous +force_install_dir /app +app_update 346680 +quit
echo -e '\n\033[1m[Commiting Delta Container to Image]\033[0m'
docker commit --change='CMD ["/bin/bash"]' --message="Content delta update $(date '+%d/%m/%Y %H:%M:%S')" "$(docker ps -aqf "name=LL-CSGO-DELTA-CAPTURE")" lacledeslan/gamesvr-csgo:latest
docker container rm LL-BLACKMESA-DELTA-CAPTURE
fi;
echo -e '\n\033[1m[Running Image Self-Checks]\033[0m';
docker run -it --rm lacledeslan/gamesvr-blackmesa:latest ./ll-tests/gamesvr-blackmesa.sh;
echo -e '\n\033[1m[Pushing to Docker Hub]\033[0m';
if [ "$option_delta_updates" != 'true' ]; then
#
# Full Update
#
docker tag lacledeslan/gamesvr-blackmesa:latest lacledeslan/gamesvr-blackmesa:base
echo "> push lacledeslan/gamesvr-blackmesa:base"
docker push lacledeslan/gamesvr-blackmesa:base
echo "> push lacledeslan/gamesvr-blackmesa:latest"
docker push lacledeslan/gamesvr-blackmesa:latest
else
#
# Delta Update
#
echo "> push lacledeslan/gamesvr-blackmesa:latest"
docker push lacledeslan/gamesvr-blackmesa:latest
fi;