Skip to content

Commit 075982e

Browse files
committed
fix(install.sh): improve setcap command handling
Enhance handling of the 'setcap' command to ensure better user experience during installation on Linux systems. - Add a check for 'setcap' command availability. - Display a warning if 'setcap' is not available, indicating potential slower transfer speeds. This ensures the script fails gracefully and informs the user when 'CAP_NET_ADMIN' capability cannot be set.
1 parent f034827 commit 075982e

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

install.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,23 @@ main() {
125125
# Run using sudo if not root
126126
if [ "$(id -u)" -ne 0 ]; then
127127
sudo sh <<EOF
128-
[ "$(uname -s)" = "Linux" ] && command -v setcap >/dev/null 2>&1 && setcap cap_net_admin=eip "$BINARY_PATH"
128+
if [ "$(uname -s)" = "Linux" ]; then
129+
if command -v setcap >/dev/null 2>&1; then
130+
setcap cap_net_admin=eip "$BINARY_PATH"
131+
else
132+
echo "Warning: 'setcap' command is not available. Transfer speeds may be slower."
133+
fi
134+
fi
129135
mv "$BINARY_PATH" "$INSTALL_DIR/$BINARY_NAME"
130136
EOF
131137
else
132-
[ "$(uname -s)" = "Linux" ] && command -v setcap >/dev/null 2>&1 && setcap cap_net_admin=eip "$BINARY_PATH"
138+
if [ "$(uname -s)" = "Linux" ]; then
139+
if command -v setcap >/dev/null 2>&1; then
140+
setcap cap_net_admin=eip "$BINARY_PATH"
141+
else
142+
echo "Warning: 'setcap' command is not available. Transfer speeds may be slower."
143+
fi
144+
fi
133145
mv "$BINARY_PATH" "$INSTALL_DIR/$BINARY_NAME"
134146
fi
135147
fi

0 commit comments

Comments
 (0)