summaryrefslogtreecommitdiff
path: root/run_server.sh
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2019-11-04 12:24:08 +0100
committerTom Smeding <tom.smeding@gmail.com>2019-11-05 10:32:41 +0100
commitd179a5b469d609a7c7f15d841dfb95fe77b3125e (patch)
treeb630dffabe6cfd70a975cd57b4044291b897fdf1 /run_server.sh
parentfa1ae45491a8e41ccde4e0b366c37ec2a067bae9 (diff)
Seqnum server
Diffstat (limited to 'run_server.sh')
-rwxr-xr-xrun_server.sh19
1 files changed, 18 insertions, 1 deletions
diff --git a/run_server.sh b/run_server.sh
index e6beee9..c3e9759 100755
--- a/run_server.sh
+++ b/run_server.sh
@@ -1,9 +1,26 @@
#!/usr/bin/env bash
+set -euo pipefail
+
if [[ "$(id -u)" -ne 0 ]]; then
echo >&2 "Run with sudo"
exit 1
fi
+if [[ $# -eq 0 ]]; then
+ server_exec=./server
+elif [[ $# -eq 1 ]]; then
+ server_exec="$1"
+else
+ echo >&2 "Usage: $0 [server executable]"
+ echo >&2 "By default runs ./server"
+ exit 1
+fi
+
+if [[ ! -x "$server_exec" ]]; then
+ echo >&2 "Cannot execute server executable $server_exec"
+ exit 1
+fi
+
echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_all
trap "echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_all" EXIT
-./serverd
+"$server_exec"