-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·50 lines (42 loc) · 1.2 KB
/
deploy.sh
File metadata and controls
executable file
·50 lines (42 loc) · 1.2 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
#!/bin/bash
echo "Alef Union Reverse Proxy deploy script
"
echo "🔗 Remote host (domain or IPv4 only):"
read REMOTE
echo
SERVICE="[Unit]
Description=Alef Union Reverse Proxy
[Service]
ExecStart=reverseproxy
WorkingDirectory=/srv
User=www
Restart=always
AmbientCapabilities=CAP_NET_BIND_SERVICE
LimitNOFILE=4096
[Install]
WantedBy=multi-user.target
"
# Build and upload binary
GOOS=linux go build -o reverseproxy
echo "🛠️ reverseproxy built for Linux"
ssh root@$REMOTE "systemctl stop reverseproxy &>/dev/null"
scp -q reverseproxy root@$REMOTE:/usr/local/sbin
echo "🚚 reverseproxy uploaded on remote server"
rm reverseproxy
# Create service
ssh root@$REMOTE "
id -u www &>/dev/null || useradd www;\
chown www:www /usr/local/sbin/reverseproxy;\
install -d -m 0755 /etc/reverseproxy;\
touch /etc/reverseproxy/hostmap;\
chmod 755 /etc/reverseproxy/hostmap;\
echo \"$SERVICE\" > /etc/systemd/system/reverseproxy.service;\
systemctl daemon-reload;\
systemctl enable reverseproxy;\
"
echo "📦 reverseproxy service created on remote server"
# Edit hostmap
ssh root@$REMOTE -qt "vi /etc/reverseproxy/hostmap"
# Start service
ssh root@$REMOTE "systemctl start reverseproxy"
echo "⚡️ reverseproxy service started"