Skip to content

Commit 91f7b14

Browse files
committed
Add Linux/macOS updater for v16+
1 parent 0a4d1fd commit 91f7b14

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

PSMUpdate.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
URL_LINUX="https://raw.githubusercontent.com/SvenGDK/PS-Multi-Tools/main/LinuxUpdate.zip"
5+
URL_MAC="https://raw.githubusercontent.com/SvenGDK/PS-Multi-Tools/main/macOSUpdate.zip"
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
8+
OS="$(uname -s)"
9+
case "$OS" in
10+
Linux) PLATFORM="linux" ;;
11+
Darwin) PLATFORM="macos" ;;
12+
FreeBSD) PLATFORM="freebsd" ;;
13+
*) PLATFORM="unknown" ;;
14+
esac
15+
16+
if [ "$PLATFORM" = "macos" ]; then
17+
URL="$URL_MAC"
18+
else
19+
URL="$URL_LINUX"
20+
fi
21+
22+
if [ "$PLATFORM" = "linux" ]; then
23+
TMP_ZIP="$(mktemp --tmpdir linuxupdate.XXXXXX)"
24+
elif [ "$PLATFORM" = "macos" ]; then
25+
TMP_ZIP="$(mktemp -t linuxupdate)"
26+
elif [ "$PLATFORM" = "freebsd" ]; then
27+
TMP_ZIP="$(mktemp /tmp/linuxupdate.XXXXXX)"
28+
else
29+
TMP_ZIP="$(mktemp)"
30+
fi
31+
32+
cleanup() {
33+
rm -f "$TMP_ZIP"
34+
}
35+
trap cleanup EXIT
36+
37+
if ! command -v unzip >/dev/null 2>&1; then
38+
if [ "$PLATFORM" = "linux" ]; then
39+
echo "Error: unzip is not installed. Install it (e.g., sudo apt install unzip) and retry." >&2
40+
elif [ "$PLATFORM" = "macos" ]; then
41+
echo "Error: unzip is not available. On macOS install via Homebrew if needed: brew install unzip" >&2
42+
elif [ "$PLATFORM" = "freebsd" ]; then
43+
echo "Error: unzip is not installed. Install it with: sudo pkg install unzip" >&2
44+
else
45+
echo "Error: unzip is not installed. Please install unzip and retry." >&2
46+
fi
47+
exit 1
48+
fi
49+
50+
echo "Platform detected: $PLATFORM"
51+
echo "Downloading $URL ..."
52+
53+
if command -v curl >/dev/null 2>&1; then
54+
curl -fL --retry 3 --retry-delay 2 -o "$TMP_ZIP" "$URL"
55+
elif command -v wget >/dev/null 2>&1; then
56+
wget -q -O "$TMP_ZIP" "$URL"
57+
elif [ "$PLATFORM" = "freebsd" ] && command -v fetch >/dev/null 2>&1; then
58+
fetch -o "$TMP_ZIP" "$URL"
59+
else
60+
echo "Error: neither curl nor wget (nor fetch on FreeBSD) is available. Install one and retry." >&2
61+
exit 1
62+
fi
63+
64+
if command -v file >/dev/null 2>&1; then
65+
if ! file -b --mime-type "$TMP_ZIP" | grep -qi 'zip'; then
66+
echo "Warning: downloaded file does not appear to be a ZIP archive." >&2
67+
fi
68+
fi
69+
70+
echo "Extracting into $SCRIPT_DIR ..."
71+
unzip -o "$TMP_ZIP" -d "$SCRIPT_DIR"
72+
73+
echo "Done. PS Multi Tools has been updated!"

0 commit comments

Comments
 (0)