Improve setup and update scripts pt.2
This commit is contained in:
@ -1,16 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# If repo isn't out of date, abort update
|
||||
# Only begin update process if necessary
|
||||
if [[ -z "$(git remote show origin | grep "out of date")" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
TOOLKIT_DIR="$SCRIPT_DIR"/..
|
||||
|
||||
# Load color script
|
||||
. "$SCRIPT_DIR"/util/color.sh
|
||||
|
||||
last_hash=$( git rev-parse HEAD )
|
||||
|
||||
recent_hashes=$( git log --format=format:%H | grep -B 100 $last_hash)
|
||||
|
||||
print_info Resetting repo and pulling latest commits...
|
||||
|
||||
# Resets the repo to last state
|
||||
git reset --hard
|
||||
|
||||
@ -24,8 +29,11 @@ git submodule update --init --recursive
|
||||
git clean -fd --force
|
||||
|
||||
# Runs patch scripts to ensure machine state
|
||||
# is up to date
|
||||
# matches toolkit state
|
||||
while IFS= read -r hash; do
|
||||
short_hash=$( echo $hash | cut -c -7 )
|
||||
/usr/bin/bash "$SCRIPT_DIR"/../patches/*-"$short_hash".sh 2>/dev/null
|
||||
short_hash=$( echo "$hash" | cut -c -7 )
|
||||
print_info Running patch script \'"$short_hash"\'
|
||||
. "$SCRIPT_DIR"/../patches/*-"$short_hash".sh 2>/dev/null
|
||||
done <<< "$recent_hashes"
|
||||
|
||||
print_info Update complete
|
||||
|
Reference in New Issue
Block a user