-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-wiredoor-cli.sh
More file actions
106 lines (93 loc) · 2.62 KB
/
install-wiredoor-cli.sh
File metadata and controls
106 lines (93 loc) · 2.62 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
#!/bin/sh
set -e
REPO="wiredoor/wiredoor-cli"
# Get latest release from GitHub API
get_latest_version() {
curl --silent "https://api.github.com/repos/$REPO/releases/latest" |
grep '"tag_name":' |
sed -E 's/.*"v?([^"]+)".*/\1/'
}
VERSION=$(get_latest_version)
detect_arch() {
ARCH=$(uname -m)
case "$ARCH" in
x86_64) echo "amd64" ;;
aarch64 | arm64) echo "arm64" ;;
*) echo "unsupported" ;;
esac
}
detect_os() {
if [ -f /etc/os-release ]; then
. /etc/os-release
case "$ID" in
debian|ubuntu|raspbian)
echo "debian"
;;
fedora|centos|almalinux|rhel)
echo "rhel"
;;
alpine)
echo "alpine"
;;
arch|manjaro)
echo "archlinux"
;;
*)
echo "unsupported"
;;
esac
else
echo "unsupported"
fi
}
ARCH=$(detect_arch)
OS=$(detect_os)
if [ "$OS" = "unsupported" ]; then
echo "❌ Unsupported OS=$OS $ID"
exit 1
fi
if [ "$ARCH" = "unsupported" ]; then
echo "❌ Unsupported ARCH=$ARCH"
exit 1
fi
if [ "$(id -u)" -eq 0 ]; then
SUDO=""
else
SUDO="sudo"
fi
echo "🔍 Detected OS: $OS, ARCH: $ARCH"
echo "📦 Installing Wiredoor CLI v$VERSION..."
case "$OS" in
debian)
URL="https://github.com/$REPO/releases/download/v$VERSION/wiredoor_${VERSION}-1_debian_${ARCH}.deb"
curl -fsSL "$URL" -o /tmp/wiredoor.deb
$SUDO apt install -f /tmp/wiredoor.deb
rm -f /tmp/wiredoor.deb
;;
rhel)
URL="https://github.com/$REPO/releases/download/v$VERSION/wiredoor_${VERSION}-1_rpm_${ARCH}.rpm"
curl -fsSL "$URL" -o /tmp/wiredoor.rpm
$SUDO dnf install -y /tmp/wiredoor.rpm || $SUDO yum install -y /tmp/wiredoor.rpm
rm -f /tmp/wiredoor.rpm
;;
alpine)
URL="https://github.com/$REPO/releases/download/v$VERSION/wiredoor_${VERSION}-1_alpine_${ARCH}.apk"
curl -fsSL "$URL" -o /tmp/wiredoor.apk
$SUDO apk add --allow-untrusted /tmp/wiredoor.apk
rm -f /tmp/wiredoor.apk
;;
archlinux)
if ! command -v iptables >/dev/null 2>&1; then
echo "[wiredoor] 'iptables' command not found."
echo "Install either 'iptables-nft' or 'iptables' and run the installer again."
exit 1
fi
URL="https://github.com/$REPO/releases/download/v$VERSION/wiredoor_${VERSION}-1_archlinux_${ARCH}.pkg.tar.zst"
curl -fsSL "$URL" -o /tmp/wiredoor.pkg.tar.zst
DEPS=$(tar -xOf /tmp/wiredoor.pkg.tar.zst .PKGINFO | grep '^depend =' | cut -d= -f2- | xargs)
$SUDO pacman -Sy --needed $DEPS
$SUDO pacman -U --noconfirm /tmp/wiredoor.pkg.tar.zst
rm -f /tmp/wiredoor.pkg.tar.zst
;;
esac
echo "✅ Wiredoor CLI installed successfully! Type wiredoor for help."