From e3b74501ea477e06243dfca0904d6034f5ecccc4 Mon Sep 17 00:00:00 2001 From: Eggers Date: Mon, 6 Mar 2023 15:38:59 +0100 Subject: [PATCH] working version, commit to get last changes --- dev.Dockerfile | 5 +-- docker/run-dev.sh | 80 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 2 deletions(-) create mode 100755 docker/run-dev.sh diff --git a/dev.Dockerfile b/dev.Dockerfile index 55dbe930c..265967f07 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -18,7 +18,8 @@ RUN go get -v && go build -v # Runtime container -FROM debian:stable-slim +##FROM debian:stable-slim +FROM golang:1.20.1 RUN useradd -m -d /opt/gophish -s /bin/bash app @@ -44,4 +45,4 @@ EXPOSE 3333 8080 8443 80 ENV GOPHISH_INITIAL_ADMIN_PASSWORD=changeme -CMD ["./docker/run.sh"] +CMD ["./docker/run-dev.sh"] diff --git a/docker/run-dev.sh b/docker/run-dev.sh new file mode 100755 index 000000000..e57328206 --- /dev/null +++ b/docker/run-dev.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +# set config for admin_server +if [ -n "${ADMIN_LISTEN_URL+set}" ] ; then + jq -r \ + --arg ADMIN_LISTEN_URL "${ADMIN_LISTEN_URL}" \ + '.admin_server.listen_url = $ADMIN_LISTEN_URL' config.json > config.json.tmp && \ + cat config.json.tmp > config.json +fi +if [ -n "${ADMIN_USE_TLS+set}" ] ; then + jq -r \ + --argjson ADMIN_USE_TLS "${ADMIN_USE_TLS}" \ + '.admin_server.use_tls = $ADMIN_USE_TLS' config.json > config.json.tmp && \ + cat config.json.tmp > config.json +fi +if [ -n "${ADMIN_CERT_PATH+set}" ] ; then + jq -r \ + --arg ADMIN_CERT_PATH "${ADMIN_CERT_PATH}" \ + '.admin_server.cert_path = $ADMIN_CERT_PATH' config.json > config.json.tmp && \ + cat config.json.tmp > config.json +fi +if [ -n "${ADMIN_KEY_PATH+set}" ] ; then + jq -r \ + --arg ADMIN_KEY_PATH "${ADMIN_KEY_PATH}" \ + '.admin_server.key_path = $ADMIN_KEY_PATH' config.json > config.json.tmp && \ + cat config.json.tmp > config.json +fi +if [ -n "${ADMIN_TRUSTED_ORIGINS+set}" ] ; then + jq -r \ + --arg ADMIN_TRUSTED_ORIGINS "${ADMIN_TRUSTED_ORIGINS}" \ + '.admin_server.trusted_origins = ($ADMIN_TRUSTED_ORIGINS|split(","))' config.json > config.json.tmp && \ + cat config.json.tmp > config.json +fi + +# set config for phish_server +if [ -n "${PHISH_LISTEN_URL+set}" ] ; then + jq -r \ + --arg PHISH_LISTEN_URL "${PHISH_LISTEN_URL}" \ + '.phish_server.listen_url = $PHISH_LISTEN_URL' config.json > config.json.tmp && \ + cat config.json.tmp > config.json +fi +if [ -n "${PHISH_USE_TLS+set}" ] ; then + jq -r \ + --argjson PHISH_USE_TLS "${PHISH_USE_TLS}" \ + '.phish_server.use_tls = $PHISH_USE_TLS' config.json > config.json.tmp && \ + cat config.json.tmp > config.json +fi +if [ -n "${PHISH_CERT_PATH+set}" ] ; then + jq -r \ + --arg PHISH_CERT_PATH "${PHISH_CERT_PATH}" \ + '.phish_server.cert_path = $PHISH_CERT_PATH' config.json > config.json.tmp && \ + cat config.json.tmp > config.json +fi +if [ -n "${PHISH_KEY_PATH+set}" ] ; then + jq -r \ + --arg PHISH_KEY_PATH "${PHISH_KEY_PATH}" \ + '.phish_server.key_path = $PHISH_KEY_PATH' config.json > config.json.tmp && \ + cat config.json.tmp > config.json +fi + +# set contact_address +if [ -n "${CONTACT_ADDRESS+set}" ] ; then + jq -r \ + --arg CONTACT_ADDRESS "${CONTACT_ADDRESS}" \ + '.contact_address = $CONTACT_ADDRESS' config.json > config.json.tmp && \ + cat config.json.tmp > config.json +fi + +if [ -n "${DB_FILE_PATH+set}" ] ; then + jq -r \ + --arg DB_FILE_PATH "${DB_FILE_PATH}" \ + '.db_path = $DB_FILE_PATH' config.json > config.json.tmp && \ + cat config.json.tmp > config.json +fi + +echo "Runtime configuration: " +cat config.json + +# start gophish +go run gophish.go