From 4438a027ece7a56d1d8295bdc8de3b623cbef53e Mon Sep 17 00:00:00 2001 From: Midgard Date: Thu, 26 Mar 2020 17:55:40 +0100 Subject: [PATCH] Put URL in separate config to avoid Git change --- .gitignore | 1 + README.md | 3 +-- rundev.sh | 25 +++++++++++++++---------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 68e4d41..dfe298d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ __pycache__/ *.pyc *.bak *~ +/config diff --git a/README.md b/README.md index 6496f28..9852a6a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -To run in development mode, change `MATTERMOST_REMOTE` in `rundev.sh` to a server where you have an -account, then execute `rundev.sh`. +To run in development mode, execute `rundev.sh`. This will start a web server, and mitmproxy to avoid CORS problems. Dependencies for that: Bash, Python and [`mitmproxy`](https://mitmproxy.org/). diff --git a/rundev.sh b/rundev.sh index f4bb835..9600878 100755 --- a/rundev.sh +++ b/rundev.sh @@ -1,18 +1,23 @@ #!/bin/bash - - -# Config -MATTERMOST_REMOTE="https://gitlab.mattermost.com" - - - set -euo pipefail cd "$(dirname "$0")" -if [[ $MATTERMOST_REMOTE == */ ]]; then - echo "MATTERMOST_REMOTE should not end with a slash (it should only the protocol and the domain; no path)" >&2 - exit 1 + +check_remote() { + if [[ $MATTERMOST_REMOTE == */ ]]; then + echo "MATTERMOST_REMOTE should not end with a slash (it should only the protocol and the domain; no path)" >&2 + exit 1 + fi +} + +if [[ ! -f config ]]; then + read -p 'Server URL (e.g. `https://mattermost.example.com`): ' MATTERMOST_REMOTE + check_remote + echo "MATTERMOST_REMOTE='$MATTERMOST_REMOTE'" > config + echo 'You can change this later by editing the file `config`.' fi +source "config" +check_remote server_pid=0 finish() {