Skip to content

Commit afcf507

Browse files
committed
fixed the script
1 parent 1af0ac6 commit afcf507

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

install.sh

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,29 @@ else
1818
exit 1
1919
fi
2020

21-
command -v unzip >/dev/null ||
22-
error 'unzip is required to install sfcompute cli'
21+
# Function to check if a command exists
22+
command_exists() {
23+
command -v "$1" >/dev/null 2>&1
24+
}
25+
26+
# Check if unzip is installed, if not, try to install it
27+
if ! command_exists unzip; then
28+
echo "unzip is not installed. Attempting to install..."
29+
if command_exists apt-get; then
30+
sudo apt-get update && sudo apt-get install -y unzip
31+
elif command_exists yum; then
32+
sudo yum install -y unzip
33+
else
34+
echo "Unable to install unzip. Please install it manually and run this script again."
35+
exit 1
36+
fi
37+
fi
38+
39+
# Verify unzip is now available
40+
if ! command_exists unzip; then
41+
echo "Failed to install unzip. Please install it manually and run this script again."
42+
exit 1
43+
fi
2344

2445
# Make sure the target dir exists
2546
mkdir -p "${TARGET_DIR}"
@@ -72,7 +93,7 @@ curl -L -o "${TMPDIR}/${BINARY_NAME}.zip" "${SF_BINARY_URL}"
7293
# Extract the zip file in the temporary directory.
7394
echo "unzip -o \"${TMPDIR}/${BINARY_NAME}.zip\" -d \"${TMPDIR}/dist\""
7495
unzip -o "${TMPDIR}/${BINARY_NAME}.zip" -d "${TMPDIR}/dist" ||
75-
error 'Failed to extract sf'
96+
{ echo "Failed to extract sf"; exit 1; }
7697

7798
# Move the binary to the target directory.
7899
mv "${TMPDIR}/dist/sf-$target" "${TARGET_DIR}/${BINARY_NAME}"
@@ -100,6 +121,9 @@ if [ -f "${TARGET_FILE}" ]; then
100121
echo -e "\033[1m echo 'export PATH=\"${TARGET_DIR}:\$PATH\"' >> ~/.zshrc && source ~/.zshrc\033[0m"
101122
echo -e "\033[0;32m"
102123
echo -e "After running the appropriate command, you can use '${BINARY_NAME}'.\033[0m"
124+
echo -e "\033[0;32m"
125+
echo -e "To get started, run: 'sf login'\033[0m"
126+
echo -e "\033[0;32m"
103127

104128
else
105129
echo "Installation failed. '${BINARY_NAME}' CLI could not be installed."

0 commit comments

Comments
 (0)