Merge pull request #12 from Pigges/startup

Save binary as a tmp file
This commit is contained in:
Chris Titus 2024-07-13 16:54:58 -05:00 committed by GitHub
commit 2c0a5f34e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 17 deletions

View File

@ -3,5 +3,5 @@
## Usage ## Usage
Open your terminal and paste this command Open your terminal and paste this command
```bash ```bash
bash <(curl -L https://raw.githubusercontent.com/ChrisTitusTech/linutil/main/start.sh) curl -fsSL https://raw.githubusercontent.com/ChrisTitusTech/linutil/main/start.sh | sh
``` ```

View File

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