Skip to content

Commit f3d0daf

Browse files
committed
Updated ipm installation script
1 parent 033e3b8 commit f3d0daf

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

install_ipm.sh

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ set -e
33

44
APPNAME="ipm"
55

6-
# Universal cross-platform user-level bin directory
7-
INSTALL_DIR="$HOME/.local/bin"
6+
# Global installation dir for Linux/macOS
7+
INSTALL_DIR="/usr/local/bin"
88

99
# Detect OS + ARCH
1010
OS="$(uname | tr '[:upper:]' '[:lower:]')"
@@ -20,14 +20,30 @@ EXT=""
2020
if [[ "$OS" == "mingw"* || "$OS" == "cygwin"* || "$OS" == "msys"* ]]; then
2121
OS="windows"
2222
EXT=".exe"
23+
INSTALL_DIR="$USERPROFILE/.local/bin"
2324
fi
2425

25-
DOWNLOAD_URL="https://github.com/HexmosTech/freeDevTools/releases/latest/download/ipm-$OS-$ARCH$EXT"
2626
TARGET="$INSTALL_DIR/$APPNAME$EXT"
27+
DOWNLOAD_URL="https://github.com/HexmosTech/freeDevTools/releases/latest/download/ipm-$OS-$ARCH$EXT"
28+
29+
###################################
30+
# On Linux/macOS, prompt for sudo upfront
31+
###################################
32+
if [[ "$OS" != "windows" ]]; then
33+
echo "==> Installation requires sudo. You may be asked for your password."
34+
sudo -v # prompt for password upfront
35+
fi
2736

28-
mkdir -p "$INSTALL_DIR"
37+
###################################
38+
# Ensure install dir exists
39+
###################################
40+
if [[ "$OS" != "windows" ]]; then
41+
sudo mkdir -p "$INSTALL_DIR"
42+
fi
2943

30-
# Check if valid binary already exists
44+
###################################
45+
# Check existing binary
46+
###################################
3147
if [[ -f "$TARGET" ]]; then
3248
if [[ "$OS" != "windows" ]]; then
3349
if [[ -x "$TARGET" ]] && file "$TARGET" | grep -q 'ELF\|Mach-O'; then
@@ -36,7 +52,7 @@ if [[ -f "$TARGET" ]]; then
3652
exit 0
3753
else
3854
echo "==> Invalid binary found, reinstalling..."
39-
rm -f "$TARGET"
55+
sudo rm -f "$TARGET"
4056
fi
4157
else
4258
echo "==> $APPNAME already exists at $TARGET"
@@ -45,12 +61,17 @@ if [[ -f "$TARGET" ]]; then
4561
fi
4662
fi
4763

64+
###################################
65+
# Download binary
66+
###################################
4867
echo "==> Installing $APPNAME ($OS-$ARCH) to $INSTALL_DIR ..."
4968
echo "==> Downloading from $DOWNLOAD_URL ..."
50-
curl -L "$DOWNLOAD_URL" -o "$TARGET"
5169

5270
if [[ "$OS" != "windows" ]]; then
53-
chmod +x "$TARGET"
71+
sudo curl -L "$DOWNLOAD_URL" -o "$TARGET"
72+
sudo chmod +x "$TARGET"
73+
else
74+
curl -L "$DOWNLOAD_URL" -o "$TARGET"
5475
fi
5576

5677
echo "==> Installation complete!"

0 commit comments

Comments
 (0)