linutil/start.sh

35 lines
618 B
Bash
Raw Normal View History

2024-07-07 23:33:47 +01:00
#!/bin/sh
2024-06-29 03:12:23 +01:00
rc='\033[0m'
red='\033[0;31m'
2024-06-29 03:12:23 +01:00
binary_url="https://github.com/ChrisTitusTech/linutil/releases/latest/download/linutil"
2024-06-29 03:12:23 +01:00
2024-07-07 23:33:47 +01:00
check() {
exit_code=$1
message=$2
2024-06-29 03:12:23 +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
unset exit_code
unset message
2024-07-07 23:33:47 +01:00
}
2024-06-29 03:12:23 +01:00
temp_file=$(mktemp)
2024-07-07 23:33:47 +01:00
check $? "Creating the temporary file"
curl -fsL "$binary_url" -o "$temp_file"
2024-07-07 23:33:47 +01:00
check $? "Downloading linutil"
chmod +x "$temp_file"
2024-07-07 23:33:47 +01:00
check $? "Making linutil executable"
"$temp_file"
2024-07-07 23:33:47 +01:00
check $? "Executing linutil"
rm -f "$temp_file"
2024-07-07 23:33:47 +01:00
check $? "Deleting the temporary file"