2020-06-29 08:43:46 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -u
|
|
|
|
|
2020-07-17 05:41:04 +00:00
|
|
|
go mod tidy
|
|
|
|
go mod vendor
|
|
|
|
go generate -mod=vendor ./...
|
|
|
|
go build -mod=vendor -o ./telebit ./cmd/telebit/*.go
|
|
|
|
if [ -n "$(command -v setcap)" ]; then
|
|
|
|
sudo setcap 'cap_net_bind_service=+ep' ./telebit
|
|
|
|
fi
|
2020-06-29 08:43:46 +00:00
|
|
|
|
|
|
|
source .env
|
|
|
|
|
2020-07-17 05:41:04 +00:00
|
|
|
# For Tunnel Relay Server
|
|
|
|
API_HOSTNAME=${API_HOSTNAME:-"devices.example.com"}
|
|
|
|
LISTEN="${LISTEN:-":80 :443"}"
|
|
|
|
|
|
|
|
# For Device Management & Authentication
|
|
|
|
AUTH_URL=${AUTH_URL:-"https://devices.example.com/api"}
|
|
|
|
|
|
|
|
# For Let's Encrypt / ACME challenges
|
2020-07-17 08:16:18 +00:00
|
|
|
ACME_RELAY_URL=${ACME_RELAY_URL:-"http://localhost:4200/api/dns"}
|
2020-07-17 07:50:55 +00:00
|
|
|
SECRET=${SECRET:-"xxxxxxxxxxxxxxxx"}
|
2020-07-17 05:41:04 +00:00
|
|
|
|
|
|
|
# For Let's Encrypt / ACME registration
|
|
|
|
ACME_AGREE=${ACME_AGREE:-}
|
2020-07-06 09:59:05 +00:00
|
|
|
ACME_EMAIL="${ACME_EMAIL:-}"
|
2020-06-29 08:43:46 +00:00
|
|
|
|
2020-07-17 05:41:04 +00:00
|
|
|
./telebit \
|
|
|
|
--api-hostname $API_HOSTNAME \
|
2020-07-09 09:03:04 +00:00
|
|
|
--auth-url $AUTH_URL \
|
2020-07-17 05:41:04 +00:00
|
|
|
--acme-agree "$ACME_AGREE" \
|
2020-07-06 09:59:05 +00:00
|
|
|
--acme-email "$ACME_EMAIL" \
|
2020-07-17 05:41:04 +00:00
|
|
|
--acme-relay-url "$ACME_RELAY_URL" \
|
2020-07-17 07:50:55 +00:00
|
|
|
--secret "$SECRET" \
|
2020-07-17 05:41:04 +00:00
|
|
|
--listen "$LISTEN"
|