-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·123 lines (107 loc) · 3.49 KB
/
install.sh
File metadata and controls
executable file
·123 lines (107 loc) · 3.49 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
#!/bin/bash
# StackPilot - LinkStack
# Self-hosted "Link in Bio" page.
# Author: Paweł (Lazy Engineer)
#
# IMAGE_SIZE_MB=550 # linkstackorg/linkstack:latest
#
# Optional environment variables:
# DOMAIN - domain for LinkStack
set -e
APP_NAME="linkstack"
STACK_DIR="/opt/stacks/$APP_NAME"
PORT=${PORT:-8090}
echo "--- 🔗 LinkStack Setup ---"
# Domain
if [ -n "$DOMAIN" ] && [ "$DOMAIN" != "-" ]; then
echo "✅ Domain: $DOMAIN"
elif [ "$DOMAIN" = "-" ]; then
echo "✅ Domain: automatic (Caddy)"
else
echo "⚠️ No domain - using localhost"
fi
sudo mkdir -p "$STACK_DIR"
cd "$STACK_DIR"
# Check if this is a first install (no files in data/)
if [ ! -f "./data/index.php" ]; then
echo "📦 First install - downloading application files..."
# Temporary container without volume
cat <<EOF | sudo tee docker-compose.yaml > /dev/null
services:
linkstack:
image: linkstackorg/linkstack
restart: "no"
EOF
# Start temporarily to copy files
sudo docker compose up -d
sleep 5
# Copy files from container to host
sudo mkdir -p data
CONTAINER_ID=$(sudo docker compose ps -q linkstack)
sudo docker cp "$CONTAINER_ID:/htdocs/." ./data/
sudo docker compose down
# Set permissions for Apache
sudo chown -R 100:101 data
echo "✅ Application files copied"
fi
# Final docker-compose with bind mount
cat <<EOF | sudo tee docker-compose.yaml > /dev/null
services:
linkstack:
image: linkstackorg/linkstack
restart: always
ports:
- "$PORT:80"
volumes:
- ./data:/htdocs
environment:
- SERVER_ADMIN=admin@localhost
- TZ=Europe/Warsaw
deploy:
resources:
limits:
memory: 256M
EOF
sudo docker compose up -d
# Health check
source /opt/stackpilot/lib/health-check.sh 2>/dev/null || true
if type wait_for_healthy &>/dev/null; then
wait_for_healthy "$APP_NAME" "$PORT" 45 || { echo "❌ Installation failed!"; exit 1; }
else
sleep 5
if sudo docker compose ps --format json | grep -q '"State":"running"'; then
echo "✅ LinkStack is running"
else
echo "❌ Container failed to start!"; sudo docker compose logs --tail 20; exit 1
fi
fi
# Caddy/HTTPS - configure reverse proxy if domain is set
if [ -n "$DOMAIN" ]; then
if command -v sp-expose &> /dev/null; then
sudo sp-expose "$DOMAIN" "$PORT"
fi
fi
echo ""
echo "✅ LinkStack started!"
echo ""
if [ -n "$DOMAIN" ] && [ "$DOMAIN" != "-" ]; then
echo "🔗 Open: https://$DOMAIN"
elif [ "$DOMAIN" = "-" ]; then
echo "🔗 Domain will be configured automatically after installation"
else
echo "🔗 Access via SSH tunnel: ssh -L $PORT:localhost:$PORT <server>"
echo " Then open: http://localhost:$PORT"
fi
echo ""
echo "════════════════════════════════════════════════════════════════"
echo "📋 SETUP WIZARD - what to choose?"
echo "════════════════════════════════════════════════════════════════"
echo ""
echo " 🎯 Are you a solopreneur / have a single profile?"
echo " → Choose SQLite and don't worry about it"
echo ""
echo " 🏢 Setting this up for a company with multiple employees?"
echo " → MySQL (use your database credentials)"
echo ""
echo " 📝 Save your admin login credentials - you'll need them later!"
echo ""