2020-03-25 22:10:19 +01:00
|
|
|
#!/bin/bash
|
2020-03-25 22:28:22 +01:00
|
|
|
set -euo pipefail
|
|
|
|
|
2022-06-08 18:03:38 +02:00
|
|
|
if [[ "${1:-}" == --help ]] || [[ "${1:-}" == -h ]]; then
|
|
|
|
echo "Feathermost rundev.sh: Run two things:" >&2
|
|
|
|
echo " - a HTTP server to serve the web application" >&2
|
|
|
|
echo " - a proxy server for a Mattermost instance to avoid CORS problems" >&2
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2020-03-25 22:28:22 +01:00
|
|
|
cd "$(dirname "$0")"
|
2020-03-26 17:55:40 +01:00
|
|
|
|
|
|
|
if [[ ! -f config ]]; then
|
|
|
|
read -p 'Server URL (e.g. `https://mattermost.example.com`): ' MATTERMOST_REMOTE
|
2022-06-08 17:30:27 +02:00
|
|
|
echo "MATTERMOST_REMOTE='${MATTERMOST_REMOTE//\//}'" > config
|
2022-06-08 18:03:38 +02:00
|
|
|
echo 'You can change this later by editing the file `config`.' >&2
|
2020-03-25 22:10:19 +01:00
|
|
|
fi
|
2020-03-26 17:55:40 +01:00
|
|
|
source "config"
|
2020-03-25 22:10:19 +01:00
|
|
|
|
2020-03-25 22:28:22 +01:00
|
|
|
server_pid=0
|
|
|
|
finish() {
|
|
|
|
if [[ $server_pid -gt 1 ]]; then kill "$server_pid" || true; server_pid=0; fi
|
|
|
|
}
|
|
|
|
trap finish EXIT
|
2020-03-25 22:10:19 +01:00
|
|
|
|
|
|
|
python3 -m "http.server" >/dev/null 2>&1 &
|
|
|
|
mitmproxy -s etc/mitm_cors.py -m "reverse:$MATTERMOST_REMOTE"
|