2022-07-25 02:29:58 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-08-26 04:39:26 +00:00
|
|
|
|
2022-07-25 02:29:58 +00:00
|
|
|
args=("$@")
|
|
|
|
self_update() {
|
2022-08-23 18:37:16 +00:00
|
|
|
|
2022-08-26 04:16:44 +00:00
|
|
|
git fetch --tags &>/dev/null
|
2022-09-01 04:54:58 +00:00
|
|
|
git reset --hard &>/dev/null
|
2022-08-23 19:05:28 +00:00
|
|
|
latest_ver=$(git describe --tags "$(git rev-list --tags --max-count=1)")
|
2022-07-30 23:10:59 +00:00
|
|
|
echo "🅂 🄴 🄻 🄵"
|
|
|
|
echo "🅄 🄿 🄳 🄰 🅃 🄴"
|
2022-08-23 18:37:16 +00:00
|
|
|
if [[ "$hs_version" != "$latest_ver" ]] ; then
|
2022-07-25 02:29:58 +00:00
|
|
|
echo "Found a new version of HeavyScript, updating myself..."
|
2022-12-27 11:02:56 +00:00
|
|
|
git checkout "$latest_ver" &>/dev/null
|
2022-07-25 02:29:58 +00:00
|
|
|
count=0
|
|
|
|
for i in "${args[@]}"
|
|
|
|
do
|
|
|
|
[[ "$i" == "--self-update" ]] && unset "args[$count]" && break
|
|
|
|
((count++))
|
|
|
|
done
|
2022-08-23 19:02:09 +00:00
|
|
|
echo "Updating from: $hs_version"
|
|
|
|
echo "Updating To: $latest_ver"
|
|
|
|
echo "Changelog:"
|
|
|
|
curl --silent "https://api.github.com/repos/HeavyBullets8/heavy_script/releases/latest" | jq -r .body
|
2022-12-27 11:02:56 +00:00
|
|
|
echo
|
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
|
2022-12-27 11:02:56 +00:00
|
|
|
else
|
2022-08-23 18:10:53 +00:00
|
|
|
echo "HeavyScript is already the latest version:"
|
|
|
|
echo -e "$hs_version\n\n"
|
2022-07-25 02:29:58 +00:00
|
|
|
fi
|
|
|
|
}
|
2022-12-27 11:02:56 +00:00
|
|
|
export -f self_update
|