-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·124 lines (112 loc) · 3.83 KB
/
Copy pathstart.sh
File metadata and controls
executable file
·124 lines (112 loc) · 3.83 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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
set -e
# Configuration
OP_ITEM_NAME="${OP_ITEM_NAME:-Foxtail}"
OP_VAULT="${OP_VAULT:-Private}"
OP_FIELD_NAME="${OP_FIELD_NAME:-auth_key}"
TAILSCALE_HOSTNAME="${TAILSCALE_HOSTNAME:-foxtail}"
TAILSCALE_TAGS="${TAILSCALE_TAGS:-}"
DEBUG="${DEBUG:-false}"
# Enable debug mode if requested
if [ "$DEBUG" = "true" ]; then
set -x
echo "🐛 Debug mode enabled"
fi
# Warn if running with default credentials
if [ ! -f ".env" ] || ! grep -qE '^VNC_PW=.+' .env 2>/dev/null; then
echo "⚠️ No VNC_PW set in .env — using default password 'foxtail'"
echo " To set a custom password: cp .env.example .env && \$EDITOR .env"
echo ""
fi
TS_AUTHKEY=$(echo "$TS_AUTHKEY" | tr -d '[:space:]')
if [ -n "$TS_AUTHKEY" ]; then
if [ "$DEBUG" = "true" ]; then
echo "✅ Using TS_AUTHKEY from environment (length: ${#TS_AUTHKEY} chars)"
else
echo "✅ Using Tailscale auth key from environment"
fi
else
echo "🔐 Retrieving Tailscale auth key from 1Password..."
if [ "$DEBUG" = "true" ]; then
echo " Vault: ${OP_VAULT}"
echo " Item: ${OP_ITEM_NAME}"
echo " Field: ${OP_FIELD_NAME}"
fi
if ! command -v op &> /dev/null; then
echo "❌ Error: No auth key found"
echo ""
echo "Either set TS_AUTHKEY directly:"
echo " TS_AUTHKEY='tskey-auth-...' task start"
echo " or add TS_AUTHKEY=... to your .env file"
echo ""
echo "Or install 1Password CLI to fetch it automatically:"
echo " https://developer.1password.com/docs/cli/get-started/"
exit 1
fi
TS_AUTHKEY=$(op read "op://${OP_VAULT}/${OP_ITEM_NAME}/${OP_FIELD_NAME}" 2>/dev/null)
TS_AUTHKEY=$(echo "$TS_AUTHKEY" | tr -d '[:space:]')
if [ -z "$TS_AUTHKEY" ]; then
echo "❌ Error: Could not retrieve Tailscale auth key from 1Password"
echo ""
echo "Expected vault: ${OP_VAULT}"
echo "Expected item: ${OP_ITEM_NAME}"
echo "Expected field: ${OP_FIELD_NAME}"
echo ""
echo "Make sure:"
echo " 1. You're signed in to 1Password CLI: op signin"
echo " 2. The item exists in the '${OP_VAULT}' vault with name '${OP_ITEM_NAME}'"
echo " 3. The Tailscale auth key is stored in the '${OP_FIELD_NAME}' field"
echo ""
echo "Alternatively, pass the key directly:"
echo " TS_AUTHKEY='tskey-auth-...' task start"
exit 1
fi
if [ "$DEBUG" = "true" ]; then
echo "✅ Auth key retrieved successfully (length after cleanup: ${#TS_AUTHKEY} chars)"
else
echo "✅ Auth key retrieved successfully"
fi
fi
echo "🚀 Starting Foxtail container..."
# Export variables for docker-compose
export TS_AUTHKEY
export TAILSCALE_HOSTNAME
export TAILSCALE_TAGS
export DEBUG
# Start the container
if [ "$DEBUG" = "true" ]; then
echo ""
echo "🐛 Starting container with debug logging..."
docker-compose up -d
echo ""
echo "Waiting for services to start..."
sleep 5
echo ""
echo "📋 Container status:"
docker ps | grep foxtail || echo " Container not found!"
echo ""
echo "📋 Supervisor process status:"
docker exec foxtail supervisorctl status 2>&1 || echo " Could not check supervisor status"
echo ""
echo "📋 Recent logs:"
docker logs foxtail --tail 30
else
docker-compose up -d
fi
echo ""
echo "✅ Container started!"
echo ""
echo "📡 Tailscale device name: ${TAILSCALE_HOSTNAME}"
echo "🌐 Access browser at: https://localhost:6901"
echo " Username: kasm_user"
echo " Password: ${VNC_PW:-foxtail}"
echo ""
if [ "$DEBUG" = "true" ]; then
echo "🐛 Debug mode enabled - watching logs (Ctrl+C to exit)..."
echo ""
docker logs -f foxtail
else
echo "To view logs: docker-compose logs -f"
echo "To enable debug mode: DEBUG=true ./start.sh"
echo "To stop: docker-compose down"
fi