2024-07-07 23:33:47 +01:00
|
|
|
#!/bin/sh
|
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-22 01:15:41 +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() {
|
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-22 01:15:41 +01:00
|
|
|
temp_file=$(mktemp)
|
2024-07-07 23:33:47 +01:00
|
|
|
check $? "Creating the temporary file"
|
|
|
|
|
2024-07-22 01:15:41 +01:00
|
|
|
curl -fsL "$binary_url" -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-24 12:42:45 +01:00
|
|
|
#if the script is being run on NixOS
|
|
|
|
if [ -f /etc/NIXOS ]; then
|
|
|
|
./nixos_start.sh "$temp_file"
|
|
|
|
check $? "Executing linutil on NixOS"
|
|
|
|
else
|
|
|
|
"$temp_file"
|
|
|
|
check $? "Executing linutil"
|
|
|
|
fi
|
2024-07-07 23:33:47 +01:00
|
|
|
|
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"
|