-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.sh
More file actions
executable file
·66 lines (56 loc) · 2.22 KB
/
client.sh
File metadata and controls
executable file
·66 lines (56 loc) · 2.22 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
#!/bin/bash
# Client Setup Script (Silverblue)
# 1. Directory & Permission Prep
echo "Preparing directories and permissions"
mkdir -p ~/.ssh ~/.cloudflared ~/.config/systemd/user/
chmod 700 ~/.ssh
# 2. Cleanup Old Bridge (Conflict Prevention)
echo "Stopping old bridge if it exists..."
systemctl --user stop nvim-bridge 2>/dev/null || true
systemctl --user disable nvim-bridge 2>/dev/null || true
# 3. Intelligent SSH Config (Prevents Duplicates)
echo "Configuring SSH..."
# We write to a temporary file then check if we should append
TEMP_CONF=$(mktemp)
cat <<EOF > "$TEMP_CONF"
Host dev.dataverdict.com.br
# Running via Podman to keep the host clean
ProxyCommand podman run --rm -i --user root -v $HOME/.cloudflared:/root/.cloudflared:Z docker.io/cloudflare/cloudflared:latest access ssh --hostname %h
EOF
if grep -q "Host dev.dataverdict.com.br" ~/.ssh/config 2>/dev/null; then
echo "Host dev.dataverdict.com.br already in config. Skipping append to avoid duplicates."
else
cat "$TEMP_CONF" >> ~/.ssh/config
echo "Added host to ~/.ssh/config"
fi
rm "$TEMP_CONF"
chmod 600 ~/.ssh/config
# 4. Create the Systemd Tunnel Service
echo "Creating systemd tunnel service..."
systemctl --user stop nvim-bridge.service
rm ~/.config/containers/systemd/nvim-bridge.container
cat <<EOF > ~/.config/containers/systemd/nvim-bridge.container
[Unit]
Description=Cloudflare Neovim Bridge (TCP)
After=network-online.target
[Container]
Image=docker.io/cloudflare/cloudflared:latest
# Mount your local cloudflared config to use your login token
Volume=%h/.cloudflared:/root/.cloudflared:Z
Exec=access tcp --hostname nvim.dataverdict.com.br --listener localhost:9999
Network=host
[Service]
Restart=always
[Install]
WantedBy=default.target
EOF
# 5. Kickoff
echo "Initializing nvim-bridge..."
systemctl --user daemon-reload
systemctl --user start nvim-bridge.service
echo "Script finished!"
echo "IMPORTANT: If this is a fresh setup, run this to log in first:"
echo "podman run --rm -it -v $HOME/.cloudflared:/root/.cloudflared:Z docker.io/cloudflare/cloudflared:latest access login dev.dataverdict.com.br"
echo "ssh developer@dev.dataverdict.com.br to enter"
echo "nvim --server localhost:9999 --remote-ui"
echo "noevide --server localhost:9999 --no-multigrid"