aboutsummaryrefslogtreecommitdiff
path: root/run_server.sh
blob: cc74379c26447229372d045736fb5851ca86ab00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

SERVER_DIR=$"./src/server/"
SERVER_NAME=$"server"
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")

cd "${SCRIPT_DIR}" || exit
if ! (npm run build) ; then
	printf "\x1b[31mnpm build failed! stopping\n\x1b[0m" >&2
	exit 1
fi

if ! (cd "${SERVER_DIR}" && go build && mv "${SERVER_NAME}" ../../); then
	printf "\x1b[31mgo build failed! stopping\n\x1b[0m" >&2
	exit 1
fi

if ! (sudo setcap 'cap_net_bind_service=+ep' "${SERVER_NAME}"); then
	# We don't return here because this might not be necessary.
	printf "\x1b[31mfailed to provide setcap privileges to binary\x1b[0m" >&2
fi

./${SERVER_NAME}