Improve rundev script
Kill server when exiting MITM
This commit is contained in:
parent
5fd8101224
commit
190663a253
1 changed files with 12 additions and 1 deletions
13
rundev.sh
13
rundev.sh
|
@ -1,14 +1,25 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
# Config
|
||||||
MATTERMOST_REMOTE="https://mattermost.zeus.gent"
|
MATTERMOST_REMOTE="https://mattermost.zeus.gent"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
cd "$(dirname "$0")"
|
||||||
if [[ $MATTERMOST_REMOTE == */ ]]; then
|
if [[ $MATTERMOST_REMOTE == */ ]]; then
|
||||||
echo "MATTERMOST_REMOTE should not end with a slash (it should only the protocol and the domain; no path)" >&2
|
echo "MATTERMOST_REMOTE should not end with a slash (it should only the protocol and the domain; no path)" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$(dirname "$0")"
|
server_pid=0
|
||||||
|
finish() {
|
||||||
|
if [[ $server_pid -gt 1 ]]; then kill "$server_pid" || true; server_pid=0; fi
|
||||||
|
}
|
||||||
|
trap finish EXIT
|
||||||
|
|
||||||
python3 -m "http.server" >/dev/null 2>&1 &
|
python3 -m "http.server" >/dev/null 2>&1 &
|
||||||
|
server_pid=$!
|
||||||
mitmproxy -s etc/mitm_cors.py -m "reverse:$MATTERMOST_REMOTE"
|
mitmproxy -s etc/mitm_cors.py -m "reverse:$MATTERMOST_REMOTE"
|
||||||
|
|
Loading…
Reference in a new issue