forked from paultyng/terraform-provider-unifi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.sh
executable file
·60 lines (55 loc) · 1.6 KB
/
controller.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
#! /bin/bash
set -eou pipefail
# Local Administrator
# Username: tfacctest
# Password: tfacctest1234
# Email: [email protected]
DOCKER_HTTP_PORT="${DOCKER_HTTP_PORT:-8080}"
DOCKER_HTTPS_PORT="${DOCKER_HTTPS_PORT:-8443}"
DOCKER_STUN_PORT="${DOCKER_STUN_PORT:-3478}"
DOCKER_AIRCONTROL_PORT="${DOCKER_AIRCONTROL_PORT:-10001}"
if test $# -eq 0; then
echo "please specify either 'start' or 'test'"
exit 1
fi
case "$1" in
"start")
docker run --rm --init -d \
-p ${DOCKER_HTTP_PORT}:8080 \
-p ${DOCKER_HTTPS_PORT}:8443 \
-p ${DOCKER_STUN_PORT}:3478/udp \
-p ${DOCKER_AIRCONTROL_PORT}:10001/udp \
-e TZ='America/New_York' \
-v $(pwd)/testdata/unifi:/unifi \
--name unifi \
jacobalberty/unifi:${2:-stable}
echo "Waiting for login page..."
timeout 300 bash -c 'while [[ "$(curl --insecure -s -o /dev/null -w "%{http_code}" '"https://localhost:${DOCKER_HTTPS_PORT}/manage/account/login"')" != "200" ]]; do sleep 5; done'
echo "Controller running."
;;
"test")
TF_ACC=1 \
UNIFI_USERNAME=tfacctest \
UNIFI_PASSWORD=tfacctest1234 \
UNIFI_API="https://localhost:${DOCKER_HTTPS_PORT}/api/" \
UNIFI_ACC_WLAN_CONCURRENCY="4" \
UNIFI_INSECURE="true" \
go test -v -cover -count 1 ./internal/provider
;;
"stop")
docker stop unifi
;;
"update")
docker pull jacobalberty/unifi:${2:-stable}
;;
"reset")
git checkout - testdata/unifi/
for file in $( git ls-files --others --exclude-standard | grep testdata/unifi ) ; do
rm -f ${file}
done
;;
*)
echo "unrecognized command"
exit 1
;;
esac