This repository has been archived by the owner on Jul 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
proxy-starter.sh
executable file
·75 lines (66 loc) · 2.14 KB
/
proxy-starter.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
################################################################################
# Help #
################################################################################
Help()
{
# Display Help
echo "Starts the playback-proxy server via uvicorn"
echo
echo "Syntax: ./proxy-starter.sh [-u|m|r|e|a|p|h]"
echo "options:"
echo "u Specify path to uvicorn"
echo "m Specify mode PROXY|RECORD|PLAYBACK"
echo "r Specify recording name"
echo "e Specify env file path"
echo "a Specify host"
echo "p Specify port"
echo "h Print this Help."
echo
}
################################################################################
################################################################################
# Main program #
################################################################################
################################################################################
while getopts "u:m:r:e:a:p:h" opt; do
case ${opt} in
u) UVICORN_PATH=${OPTARG} ;;
m) MODE=${OPTARG} ;;
r) RECORDING=${OPTARG} ;;
e) ENV_PATH=${OPTARG} ;;
a) HOST=${OPTARG} ;;
p) PORT=${OPTARG} ;;
h) Help
exit ;;
\?) echo "Error: Invalid option"
exit;;
esac
done
if [ -z ${UVICORN_PATH+x} ];
then
echo "UVICORN_PATH -u is not set"
exit 1
fi
if [ -z ${ENV_PATH+x} ];
then
echo "ENV_PATH -e is not set"
exit 1
fi
if [ -z ${HOST+x} ];
then
echo "HOST -a is not set"
exit 1
fi
if [ -z ${PORT+x} ];
then
echo "PORT -p is not set"
exit 1
fi
if [ -n "$MODE" ] && [ -n "${RECORDING}" ]
then
echo "Setting ${MODE} mode, ${RECORDING} record name to env file at ${ENV_PATH}"
sed -i '' -E "s|MODE=\"(..*)\"|MODE=\"${MODE}\"|g" "${ENV_PATH}"
sed -i '' -E "s|RECORDING=\"(..*)\"|RECORDING=\"${RECORDING}\"|g" "${ENV_PATH}"
fi
$UVICORN_PATH --app-dir ./playback-proxy/ main:app --host "${HOST}" --port "${PORT}" --log-level info --no-access-log --env-file "${ENV_PATH}"