From 9a34589e460ada4ee2a578b4413eb2bb18aa2264 Mon Sep 17 00:00:00 2001 From: Eugene Lim Date: Sun, 24 Mar 2019 19:56:05 +0800 Subject: [PATCH 1/2] Add setup script --- setup.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 setup.sh diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..8a062d1 --- /dev/null +++ b/setup.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +usage() { echo "Usage: $0 -h [-p DB password]" 1>&2; exit 1; } + +if ! [ -x "$(command -v docker)" ]; then + echo "Please install docker before continuing" + exit 1 +fi + +if ! [ -x "$(command -v docker-compose)" ]; then + echo "Please install docker-compose before continuing" + exit 1 +fi + +while getopts ":h:p:" o; do + case "${o}" in + h) + h=${OPTARG} + ;; + p) + p=${OPTARG} + ;; + *) + usage + ;; + esac +done +shift $((OPTIND-1)) + +if [ -z "${h}" ]; then + echo "asd" + usage +fi + +s=$(python -c "import random;secret=''.join('%02x' % random.randrange(256) for i in xrange(32));print secret") + +echo "Setting up with the following parameters:" +echo "IP/Domain: ${h}" +if ! [ -z "${p}" ]; then + echo "DB Password: ${p}" +fi +echo "App Secret: ${s}" + +sed -i '' "s/SECRET HERE/$s/g" main.py + +if ! [ -z "${p}" ]; then + sed -i '' "s/dbpassword/$p/g" docker-compose.yml + sed -i '' "s/dbpassword/$p/g" model.py +fi + +sed -i '' "s/ssrftest.com/$h/g" handlers/target.py +sed -i '' "s/ssrftest.com/$h/g" templates/target/index.html + +./build-docker.sh + +docker-compose up \ No newline at end of file From 7c05fffaee40641f4329ef3f8c09674d4dc58364 Mon Sep 17 00:00:00 2001 From: Eugene Lim Date: Sun, 24 Mar 2019 20:00:30 +0800 Subject: [PATCH 2/2] Update setup.sh Removed debug echo. --- setup.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index 8a062d1..3cbdc79 100755 --- a/setup.sh +++ b/setup.sh @@ -28,7 +28,6 @@ done shift $((OPTIND-1)) if [ -z "${h}" ]; then - echo "asd" usage fi @@ -53,4 +52,4 @@ sed -i '' "s/ssrftest.com/$h/g" templates/target/index.html ./build-docker.sh -docker-compose up \ No newline at end of file +docker-compose up