2022-07-25 02:29:58 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
args=("$@")
|
|
|
|
self_update() {
|
|
|
|
git fetch &> /dev/null
|
2022-07-30 23:10:59 +00:00
|
|
|
echo "🅂 🄴 🄻 🄵"
|
|
|
|
echo "🅄 🄿 🄳 🄰 🅃 🄴"
|
2022-07-29 19:15:50 +00:00
|
|
|
if git diff --name-only origin/main | grep -qs ".sh" ; then
|
2022-07-25 02:29:58 +00:00
|
|
|
echo "Found a new version of HeavyScript, updating myself..."
|
|
|
|
git reset --hard -q
|
|
|
|
git pull --force -q
|
|
|
|
count=0
|
|
|
|
for i in "${args[@]}"
|
|
|
|
do
|
|
|
|
[[ "$i" == "--self-update" ]] && unset "args[$count]" && break
|
|
|
|
((count++))
|
|
|
|
done
|
2022-07-31 18:56:50 +00:00
|
|
|
[[ -z ${args[*]} ]] && echo -e "No more arguments, exiting..\n\n" && exit
|
|
|
|
echo -e "Running the new version...\n\n"
|
2022-07-25 02:29:58 +00:00
|
|
|
sleep 5
|
|
|
|
exec bash "$script_name" "${args[@]}"
|
|
|
|
# Now exit this old instance
|
|
|
|
exit
|
|
|
|
else
|
2022-07-31 18:56:50 +00:00
|
|
|
echo -e "HeavyScript is already the latest version\n\n"
|
2022-07-25 02:29:58 +00:00
|
|
|
fi
|
|
|
|
}
|
2022-07-29 19:15:50 +00:00
|
|
|
export -f self_update
|