-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·158 lines (137 loc) · 4.34 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·158 lines (137 loc) · 4.34 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/sh
# Installation script for delinea-netconfig
# Usage: curl -sfL https://raw.githubusercontent.com/DelineaXPM/delinea-netconfig/main/install.sh | sh
set -e
# Detect OS
OS=$(uname -s)
ARCH=$(uname -m)
# Map OS to GoReleaser naming
case "$OS" in
Linux)
OS="Linux"
;;
Darwin)
OS="Darwin"
;;
*)
echo "Unsupported operating system: $OS"
exit 1
;;
esac
# Map architecture to GoReleaser naming
case "$ARCH" in
x86_64)
ARCH="x86_64"
;;
amd64)
ARCH="x86_64"
;;
arm64)
ARCH="arm64"
;;
aarch64)
ARCH="arm64"
;;
i386|i686)
ARCH="i386"
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac
# Get latest version from GitHub API
echo "Fetching latest release..."
API_RESPONSE=$(curl -s https://api.github.com/repos/DelineaXPM/delinea-netconfig/releases/latest)
LATEST_VERSION=$(echo "$API_RESPONSE" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$LATEST_VERSION" ]; then
echo ""
echo "Error: Failed to fetch latest version from GitHub API."
echo ""
echo "API response was:"
echo "$API_RESPONSE" | head -5
echo ""
echo "Possible causes:"
echo " - The repository may not be publicly accessible"
echo " - No releases have been published yet"
echo " - GitHub API rate limit exceeded (try again in a few minutes)"
echo ""
echo "Manual install: download a release from https://github.com/DelineaXPM/delinea-netconfig/releases"
exit 1
fi
echo "Latest version: $LATEST_VERSION"
# Construct download URL
BINARY_NAME="delinea-netconfig_${LATEST_VERSION#v}_${OS}_${ARCH}.tar.gz"
DOWNLOAD_URL="https://github.com/DelineaXPM/delinea-netconfig/releases/download/${LATEST_VERSION}/${BINARY_NAME}"
echo "Downloading from: $DOWNLOAD_URL"
# Download to temporary directory
TMP_DIR=$(mktemp -d)
trap "rm -rf $TMP_DIR" EXIT
cd "$TMP_DIR"
# Download and extract
if command -v curl >/dev/null 2>&1; then
curl -LO "$DOWNLOAD_URL"
elif command -v wget >/dev/null 2>&1; then
wget "$DOWNLOAD_URL"
else
echo "Neither curl nor wget found. Please install one of them."
exit 1
fi
# Download checksums
CHECKSUMS_URL="https://github.com/DelineaXPM/delinea-netconfig/releases/download/${LATEST_VERSION}/checksums.txt"
echo "Verifying checksum..."
if command -v curl >/dev/null 2>&1; then
curl -sLO "$CHECKSUMS_URL"
elif command -v wget >/dev/null 2>&1; then
wget -q "$CHECKSUMS_URL"
fi
# Verify checksum
EXPECTED_HASH=$(grep "$BINARY_NAME" checksums.txt | awk '{print $1}')
if [ -z "$EXPECTED_HASH" ]; then
echo "Error: Could not find checksum for $BINARY_NAME in checksums.txt"
exit 1
fi
if command -v sha256sum >/dev/null 2>&1; then
ACTUAL_HASH=$(sha256sum "$BINARY_NAME" | awk '{print $1}')
elif command -v shasum >/dev/null 2>&1; then
ACTUAL_HASH=$(shasum -a 256 "$BINARY_NAME" | awk '{print $1}')
else
echo "Warning: No SHA256 tool found, skipping checksum verification"
ACTUAL_HASH="$EXPECTED_HASH"
fi
if [ "$ACTUAL_HASH" != "$EXPECTED_HASH" ]; then
echo "Error: Checksum verification failed!"
echo " Expected: $EXPECTED_HASH"
echo " Actual: $ACTUAL_HASH"
echo "The downloaded file may be corrupted or tampered with."
exit 1
fi
echo "Checksum verified: OK"
# Extract
tar -xzf "$BINARY_NAME"
# Determine install location
INSTALL_DIR="/usr/local/bin"
if [ ! -w "$INSTALL_DIR" ]; then
echo "No write permission to $INSTALL_DIR. Trying with sudo..."
sudo mkdir -p "$INSTALL_DIR"
sudo mv delinea-netconfig "$INSTALL_DIR/"
else
mkdir -p "$INSTALL_DIR"
mv delinea-netconfig "$INSTALL_DIR/"
fi
# Make executable
if [ -w "$INSTALL_DIR/delinea-netconfig" ]; then
chmod +x "$INSTALL_DIR/delinea-netconfig"
else
sudo chmod +x "$INSTALL_DIR/delinea-netconfig"
fi
echo ""
echo "✓ delinea-netconfig installed successfully to $INSTALL_DIR/delinea-netconfig"
echo ""
echo "Run 'delinea-netconfig --help' to get started"
echo "Run 'delinea-netconfig version' to verify installation"
echo ""
echo "Shell completion:"
echo " Bash: delinea-netconfig completion bash > /etc/bash_completion.d/delinea-netconfig"
echo " Zsh: delinea-netconfig completion zsh > \"\${fpath[1]}/_delinea-netconfig\""
echo " Fish: delinea-netconfig completion fish > ~/.config/fish/completions/delinea-netconfig.fish"