diff --git a/start.sh b/start.sh index 72855cef..a940e3e4 100644 --- a/start.sh +++ b/start.sh @@ -1,21 +1,31 @@ -#!/bin/bash +#!/bin/sh -RC='\e[0m' -RED='\e[31m' -YELLOW='\e[33m' -GREEN='\e[32m' +RC='\033[0m' +RED='\033[0;31m' -# Check if the home directory and linuxtoolbox folder exist, create them if they don't -LINUXTOOLBOXDIR="$HOME/linuxtoolbox" +linutil="https://github.com/ChrisTitusTech/linutil/raw/main/linutil" -if [[ ! -d "$LINUXTOOLBOXDIR" ]]; then - echo -e "${YELLOW}Creating linuxtoolbox directory: $LINUXTOOLBOXDIR${RC}" - mkdir -p "$LINUXTOOLBOXDIR" - echo -e "${GREEN}linuxtoolbox directory created: $LINUXTOOLBOXDIR${RC}" -fi +check() { + local exit_code=$1 + local message=$2 -cd "$LINUXTOOLBOXDIR" || exit + if [ $exit_code -ne 0 ]; then + echo "${RED}ERROR: $message${RC}" + exit 1 + fi +} -curl -L https://github.com/ChrisTitusTech/linutil/raw/main/linutil -o linutil -chmod +x ./linutil -./linutil \ No newline at end of file +TMPFILE=$(mktemp) +check $? "Creating the temporary file" + +curl -fsL $linutil -o $TMPFILE +check $? "Downloading linutil" + +chmod +x $TMPFILE +check $? "Making linutil executable" + +"$TMPFILE" +check $? "Executing linutil" + +rm -f $TMPFILE +check $? "Deleting the temporary file"