add noupdate option

noupdate allows you to run the script without updating from github.

allows someone to customise their script without it being overwritten
This commit is contained in:
SgtBatten 2019-04-24 14:05:33 +10:00 committed by taniman
parent e1982efc8a
commit bb4a7d77cd
1 changed files with 23 additions and 15 deletions

View File

@ -14,6 +14,11 @@
### cd to the directory you have it in e.g cd /var/opt
### execute using ./linux-update.sh to downlaod the latest github release
### OPTIONS ### ./update.sh option1 option2
### This script can be executed with some optional parameters
### auto - automaticlaly upgrade without any confirmation to the latest version
### noupdate - do not update the script from github
### INSTALL DEPENDENCIES ###
### Check if unzip is installed ###
@ -55,23 +60,26 @@ export LC_ALL='en_US.UTF-8'
DIR=$(dirname "$(readlink -f "$0")")
script=$(basename "$0")
### Update linux-update script ###
### -s silent -O output to a file ###
curl -s https://raw.githubusercontent.com/taniman/profit-trailer/master/update.sh -O > /dev/null
### Get line containing LAST UPDATED (line 4 typically) ###
### -i ignore case, -m 1 match only first instance ###
olddate=$(grep -i -m 1 'updated' "$DIR"/"$script")
newdate=$(grep -i -m 1 'updated' update.sh)
if [[ ! $olddate == $newdate ]]; then
mv -f update.sh "$DIR"/"$script" 2>/dev/null
chmod +x "$DIR"/"$script"
if [[ ! $1 ]]; then
exec "$DIR"/"$script"
else
exec "$DIR"/"$script" "$@"
if [[ ! "$@" == *"noupdate"* ]]; then
### Update linux-update script ###
### -s silent -O output to a file ###
curl -s https://raw.githubusercontent.com/taniman/profit-trailer/master/update.sh -O > /dev/null
### Get line containing LAST UPDATED (line 4 typically) ###
### -i ignore case, -m 1 match only first instance ###
olddate=$(grep -i -m 1 'updated' "$DIR"/"$script")
newdate=$(grep -i -m 1 'updated' update.sh)
if [[ ! $olddate == $newdate ]]; then
mv -f update.sh "$DIR"/"$script" 2>/dev/null
chmod +x "$DIR"/"$script"
if [[ ! $1 ]]; then
exec "$DIR"/"$script"
else
exec "$DIR"/"$script" "$@"
fi
fi
else
echo "Skipped script update"
fi
### Clear screen and print header ###
clear
echo $(tput setaf 3)