From e7b711b3ad88ba7b1d8fbece220736c83ddc8ab0 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Tue, 6 Mar 2018 23:02:11 +0100 Subject: [PATCH] Move config.py to default_config.py and make deplay.bash not delete config.py on the remote --- .gitignore | 2 +- README.md | 3 +-- config.py => default_config.py | 0 deploy.bash | 8 ++++++-- main.py | 6 ++++++ 5 files changed, 14 insertions(+), 5 deletions(-) rename config.py => default_config.py (100%) diff --git a/.gitignore b/.gitignore index 1ff648e..7fe82f0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ *.pyc __pycache__ -config.ini +config.py diff --git a/README.md b/README.md index 211a829..36ae411 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,7 @@ When finished, you may run the server with: python3 main.py The server should now be available at `http://localhost:8080/`. -You may change the address and port in the file named `config.py` - +You may change the address and port in the file named `config.py` which is copied from `default_config.py` when running `main.py` the first time ## Making Grzegorz run on boot diff --git a/config.py b/default_config.py similarity index 100% rename from config.py rename to default_config.py diff --git a/deploy.bash b/deploy.bash index 6cf73cd..e84f712 100755 --- a/deploy.bash +++ b/deploy.bash @@ -10,14 +10,18 @@ array=(); while IFS= read -rd '' item; do array+=("$item"); done < \ files_not_ignored=("${array[@]}") ssh -T "$TARGET" " - rm -rf $TARGET_PATH - mkdir -p $TARGET_PATH + mv -v '$TARGET_PATH/config.py' /tmp/grzegorz_config.py + rm -rfv $TARGET_PATH + mkdir -pv $TARGET_PATH + mv -v /tmp/grzegorz_config.py '$TARGET_PATH/config.py' " +echo '== Copying files to target: ==' tar -c "${files_not_ignored[@]}" | ssh -T "$TARGET" " tar -vxC $TARGET_PATH " +echo '== DONE: ==' ssh -T "$TARGET" " systemctl --user restart grzegorz@0 diff --git a/main.py b/main.py index 4270d27..e1d84f4 100755 --- a/main.py +++ b/main.py @@ -1,6 +1,12 @@ #!/usr/bin/env python3 +import os, shutil import asyncio import grzegorz + +basedir = os.path.dirname(os.path.abspath(__file__)) +if not os.path.exists(os.path.join(basedir, "config.py")): + print("copying default_config.py to config.py...") + shutil.copy(os.path.join(basedir, "default_config.py"), os.path.join(basedir, "config.py")) import config async def grzegorz_splash():