From f196b26b79ffd82e305641c8d41ec4e5fcf26c5c Mon Sep 17 00:00:00 2001 From: Peter Molnar Date: Wed, 10 Apr 2019 09:37:24 +0100 Subject: [PATCH] - README entry about liveserver rsync+ssh sync - fail to run if keys.py is missing - try-catch for sync because it's optional w --- README.md | 16 ++++++++++++++++ nasg.py | 19 +++++++++++-------- run | 5 +++++ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 53e0abf..e462392 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,22 @@ Install the pip dependency packages by using the Pipfile by running: `pipenv install` +#### SSH (optional) + +Once the build is done, NASG will attempt to sync the output folder to a remote server. It needs an entry in the `~/.ssh/config` file: + +``` +Host liveserver + HostName your.ssh.host + User your.ssh.user + IdentityFile ~/.ssh/your.ssh.identity.file + IdentitiesOnly yes + ServerAliveInterval 30 + +``` + +Note: if you don't have this, there will be no auto upload, but the build will still succeed. + ### Prepare Create a local base directory where your contents will be put into. Eg: diff --git a/nasg.py b/nasg.py index daaff3b..b1dd720 100644 --- a/nasg.py +++ b/nasg.py @@ -2342,15 +2342,18 @@ def make(): if not settings.args.get('nosync'): # upload site - logger.info('starting syncing') - os.system( - "rsync -avuhH --delete-after %s/ %s/" % ( - settings.paths.get('build'), - '%s/%s' % (settings.syncserver, - settings.paths.get('remotewww')) + try: + logger.info('starting syncing') + os.system( + "rsync -avuhH --delete-after %s/ %s/" % ( + settings.paths.get('build'), + '%s/%s' % (settings.syncserver, + settings.paths.get('remotewww')) + ) ) - ) - logger.info('syncing finished') + logger.info('syncing finished') + except Exception as e: + logger.error('syncing failed: %s', e) if not settings.args.get('nosync'): logger.info('sending webmentions') diff --git a/run b/run index 7439674..52dd871 100755 --- a/run +++ b/run @@ -3,4 +3,9 @@ set -euo pipefail IFS=$'\n\t' +if [ ! -f 'keys.py' ]; then + echo "missing keys.py file; please copy keys.dist.py to keys.py and fill in the needed values inside" + exit 1 +fi + python3 nasg.py "$@"