aboutsummaryrefslogtreecommitdiff
path: root/run_server.sh
diff options
context:
space:
mode:
authorNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-13 18:04:18 +1100
committerNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-13 18:04:18 +1100
commit93dfe2be64e8658839bcfe5356adf35f8cde7075 (patch)
treec60b1e20d569b74dbde85123e1b2bf3590c66244 /run_server.sh
initial commit
Diffstat (limited to 'run_server.sh')
-rwxr-xr-xrun_server.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/run_server.sh b/run_server.sh
new file mode 100755
index 0000000..cc74379
--- /dev/null
+++ b/run_server.sh
@@ -0,0 +1,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}