aboutsummaryrefslogtreecommitdiff
path: root/server.sh
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2019-02-14 20:26:09 -0500
committerMitch Riedstra <mitch@riedstra.us>2019-02-14 20:26:09 -0500
commitbd13ba3f12da9721ae9e0a81af788a3f9d9bb8f8 (patch)
treed88c28b69dd421fdbbdc6833e9590c0a28ee4c0b /server.sh
downloadrshsh-bd13ba3f12da9721ae9e0a81af788a3f9d9bb8f8.tar.gz
rshsh-bd13ba3f12da9721ae9e0a81af788a3f9d9bb8f8.tar.xz
Initial
Diffstat (limited to 'server.sh')
-rwxr-xr-xserver.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/server.sh b/server.sh
new file mode 100755
index 0000000..32d7fe0
--- /dev/null
+++ b/server.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+. ./vars
+
+help() {
+cat <<EOF
+Usage: $0 [ -p <port> ] [ -k <key> ]
+ -p Sets the port it will listen on
+ -k specifies the key bundle that will be used
+EOF
+}
+
+while [ $# -gt 0 ] ; do case $1 in
+ -p) port="$2"; shift ; shift ;;
+ -k) key="$2"; shift ; shift ;;
+ *) help ;;
+esac ; done
+
+if ! [ -e "$key" ] ; then
+ openssl req -newkey rsa:2048 -nodes -keyout "${basename}.key" -x509 -days 3000 -out "${basename}.crt"
+ cat "${basename}.key" "${basename}.crt" > "${basename}.pem"
+fi
+
+socat OPENSSL-LISTEN:${port},cert=${key},reuseaddr,verify=0,fork EXEC:lib/spawn