-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsetup-https.sh
More file actions
executable file
·47 lines (37 loc) · 1.08 KB
/
Copy pathsetup-https.sh
File metadata and controls
executable file
·47 lines (37 loc) · 1.08 KB
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
#!/usr/bin/env bash
set -euo pipefail
CERT_DIR="${HOME}/.config/lumbergh"
CERT_FILE="${CERT_DIR}/tls.crt"
KEY_FILE="${CERT_DIR}/tls.key"
# Check tailscale is installed
if ! command -v tailscale &>/dev/null; then
echo "Error: tailscale is not installed."
echo "Install it from https://tailscale.com/download"
exit 1
fi
# Check tailscale is connected
if ! tailscale status &>/dev/null; then
echo "Error: tailscale is not connected. Run 'tailscale up' first."
exit 1
fi
# Get FQDN
FQDN=$(tailscale status --self --json | python3 -c "import sys,json; print(json.load(sys.stdin)['Self']['DNSName'].rstrip('.'))")
if [ -z "$FQDN" ]; then
echo "Error: could not determine Tailscale FQDN."
exit 1
fi
echo "Tailscale FQDN: ${FQDN}"
mkdir -p "$CERT_DIR"
# Generate certs
echo "Generating TLS certs (may require sudo)..."
sudo tailscale cert \
--cert-file "$CERT_FILE" \
--key-file "$KEY_FILE" \
"$FQDN"
sudo chown "$USER" "$CERT_FILE" "$KEY_FILE"
echo ""
echo "Done! Certs written to ${CERT_DIR}/"
echo "Restart the dev server and open:"
echo ""
echo " https://${FQDN}:5420"
echo ""