2022-07-25 02:29:58 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
args=("$@")
|
|
|
|
self_update() {
|
|
|
|
git fetch &> /dev/null
|
2022-07-28 19:55:35 +00:00
|
|
|
echo "🅂 🄴 🄻 🄵 🅄 🄿 🄳 🄰 🅃 🄴 :"
|
2022-07-28 20:05:21 +00:00
|
|
|
# TODO: change beta to main once testing is complete
|
2022-07-26 22:25:38 +00:00
|
|
|
if git diff --name-only origin/beta | 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-28 20:06:10 +00:00
|
|
|
[[ -z ${args[*]} ]] && echo "No more arguments, exiting.." && exit
|
2022-07-28 20:02:57 +00:00
|
|
|
echo -e "Running the new version...\n"
|
2022-07-25 02:29:58 +00:00
|
|
|
sleep 5
|
|
|
|
exec bash "$script_name" "${args[@]}"
|
|
|
|
# Now exit this old instance
|
|
|
|
exit
|
|
|
|
else
|
|
|
|
echo -e "HeavyScript is already the latest version\n"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
export -f self_update
|