2024-09-16 02:23:53 +01:00
|
|
|
#!/bin/sh -e
|
2024-06-29 03:12:23 +01:00
|
|
|
|
2024-07-22 01:15:41 +01:00
|
|
|
rc='\033[0m'
|
|
|
|
red='\033[0;31m'
|
2024-06-29 03:12:23 +01:00
|
|
|
|
2024-07-07 23:33:47 +01:00
|
|
|
check() {
|
2024-07-22 01:15:41 +01:00
|
|
|
exit_code=$1
|
|
|
|
message=$2
|
2024-06-29 03:12:23 +01:00
|
|
|
|
2024-07-22 01:15:41 +01:00
|
|
|
if [ "$exit_code" -ne 0 ]; then
|
|
|
|
printf '%sERROR: %s%s\n' "$red" "$message" "$rc"
|
2024-07-07 23:33:47 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2024-07-22 01:15:41 +01:00
|
|
|
|
|
|
|
unset exit_code
|
|
|
|
unset message
|
2024-07-07 23:33:47 +01:00
|
|
|
}
|
2024-06-29 03:12:23 +01:00
|
|
|
|
2024-07-30 22:04:46 +01:00
|
|
|
findArch() {
|
|
|
|
case "$(uname -m)" in
|
|
|
|
x86_64|amd64) arch="x86_64" ;;
|
|
|
|
aarch64|arm64) arch="aarch64" ;;
|
|
|
|
*) check 1 "Unsupported architecture"
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
getUrl() {
|
|
|
|
case "${arch}" in
|
|
|
|
x86_64) echo "https://github.com/ChrisTitusTech/linutil/releases/latest/download/linutil";;
|
|
|
|
*) echo "https://github.com/ChrisTitusTech/linutil/releases/latest/download/linutil-${arch}";;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
findArch
|
2024-07-22 01:15:41 +01:00
|
|
|
temp_file=$(mktemp)
|
2024-07-07 23:33:47 +01:00
|
|
|
check $? "Creating the temporary file"
|
|
|
|
|
2024-07-30 22:04:46 +01:00
|
|
|
curl -fsL "$(getUrl)" -o "$temp_file"
|
2024-07-07 23:33:47 +01:00
|
|
|
check $? "Downloading linutil"
|
|
|
|
|
2024-07-22 01:15:41 +01:00
|
|
|
chmod +x "$temp_file"
|
2024-07-07 23:33:47 +01:00
|
|
|
check $? "Making linutil executable"
|
|
|
|
|
2024-07-22 01:15:41 +01:00
|
|
|
"$temp_file"
|
2024-07-07 23:33:47 +01:00
|
|
|
check $? "Executing linutil"
|
|
|
|
|
2024-07-22 01:15:41 +01:00
|
|
|
rm -f "$temp_file"
|
2024-07-07 23:33:47 +01:00
|
|
|
check $? "Deleting the temporary file"
|