linutil/start.sh

41 lines
774 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"
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
rm -f "$temp_file"
2024-07-07 23:33:47 +01:00
check $? "Deleting the temporary file"