-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbpub.sh
More file actions
executable file
·123 lines (98 loc) · 3.38 KB
/
Copy pathbpub.sh
File metadata and controls
executable file
·123 lines (98 loc) · 3.38 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
## Copyright (c) 2024 Akop Karapetyan
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
# Stages, builds and deploys publisher to game server host
# Change to the script's directory
cd "$(dirname "$0")"
set -e
# Text formatting constants
BOLD_WHITE="$(tput bold)$(tput setaf 7)"
CLR_OK="$(tput setaf 2)"
CLR_WARN="$(tput setaf 3)"
CLR_ERR="$(tput setaf 1)"
CLR_RST="$(tput sgr0)"
# Check prerequisites
if [ ! -f "deploy.yaml" ]; then
echo "${CLR_ERR}Error: deploy.yaml not found${CLR_RST}" >&2
exit 1
elif ! command -v yq &> /dev/null; then
echo "${CLR_ERR}Error: yq is not installed${CLR_RST}" >&2
exit 1
fi
BUILD_SVR=`yq e '.common.build_host' deploy.yaml`
if [ -z "${BUILD_SVR}" ]; then
echo "${CLR_ERR}Error: missing build server hostname in deploy.yaml${CLR_RST}" >&2
exit 1
fi
GAME_SVR_HOST=`yq e '.game_server.hostname' deploy.yaml`
if [ -z "${GAME_SVR_HOST}" ]; then
echo "${CLR_ERR}Error: missing game server hostname in deploy.yaml${CLR_RST}" >&2
exit 1
fi
CORES_PATH=`yq e '.game_server.cores_path' deploy.yaml`
if [ -z "${CORES_PATH}" ]; then
echo "${CLR_ERR}Error: missing cores path in deploy.yaml${CLR_RST}" >&2
exit 1
fi
LOCAL_APP_PATH=pubsub
BUILD_PATH="red_builds/${LOCAL_APP_PATH}"
TARGET=pub
# Stage build
echo -e "${BOLD_WHITE}>> ${CLR_OK}Staging build... ${CLR_RST}"
ssh "${BUILD_SVR}" "mkdir -p \"${BUILD_PATH}\""
rsync -trphL \
--info=progress2 \
--exclude '.*' \
"${LOCAL_APP_PATH}/" \
"${BUILD_SVR}:${BUILD_PATH}"
# Build on build server
echo -e "${BOLD_WHITE}>> ${CLR_OK}Building... ${CLR_RST}"
ssh "${BUILD_SVR}" "cd ${BUILD_PATH} && make ${TARGET}"
# Copy the generated executable locally
TEMP_FILE=`mktemp`
rsync -trph \
"${BUILD_SVR}:${BUILD_PATH}/${TARGET}" \
"${TEMP_FILE}"
# Deploy to game server host
echo -e "${BOLD_WHITE}>> ${CLR_OK}Deploying... ${CLR_RST}"
ssh "${GAME_SVR_HOST}" "mkdir -p \"${CORES_PATH}\""
rsync -trph \
--info=progress2 \
"${TEMP_FILE}" \
"${GAME_SVR_HOST}:${CORES_PATH}/${TARGET}"
echo -e "${BOLD_WHITE}>> ${CLR_OK}All done... ${CLR_RST}"
# APP_PATH=pubsub
# BUILD_PATH="red_builds/${APP_PATH}"
# TARGET=$1
# shift
# set -e
# echo -e "${BOLD_WHITE}>> ${CLR_OK}Staging build... ${CLR_RST}"
# rsync -trph \
# --info=progress2 \
# --exclude '.*' \
# "${APP_PATH}/" \
# "${BUILD_SVR}:${BUILD_PATH}/"
# echo -e "${BOLD_WHITE}>> ${CLR_OK}Building... ${CLR_RST}"
# ssh $BUILD_SVR -t "cd ${BUILD_PATH} && make ${TARGET}"
# GAME_SVR_HOST=`yq e '.game_server.hostname' deploy.yaml`
# if [ -z "$GAME_SVR_HOST" ]; then
# echo "${CLR_ERR}Error: missing game server hostname in deploy.yaml${CLR_RST}" >&2
# exit 1
# fi
# GAME_SVR_PATH=`yq e '.game_server.path' deploy.yaml`
# if [ -z "$GAME_SVR_PATH" ]; then
# echo "${CLR_ERR}Error: missing game server path in deploy.yaml${CLR_RST}" >&2
# exit 1
# fi
# echo -e "${BOLD_WHITE}>> ${CLR_OK}All done... ${CLR_RST}"