A drop in bash script that can be added to any bash application/CLI to automate updating
MIT License
If you have a bash application/script that has an installer script and you host the project on github this script can automate updating.
git clone https://github.com/alexanderepstein/bsupdate
git checkout v2.2.1
chmod a+x updateutility.sh
while getopts ":uht:" opt; do
case $opt in
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
t)
#do stuff
;;
h)
#do stuff
;;
u)
./updateutility.sh #calling the update utility
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
if [[ "$1" == "--update" || "$1" == "-u" ]]; then
./updateutility.sh ## calling the update utility
exit 0
fi
Then use either one of the above examples but instead of calling ./updateutility.sh
just call
getConfiguredClient || exit 1
checkInternet || exit 1
latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '"name":.*?[^\\]",'| head -1 | grep -Eo "[0-9.]+" ) #always grabs the tag without the v option
update || exit 1
There is no quick way to do this as the updater requires information from the user so it cannot just replace the code without having access to these variables. I could workaround around this by having two files, but that would make it harder for the end user to implement whereas this is supposed to be simple to setup. For now just it would make sense to watch the repository if you use it so that you will be notified for updates to bsupdate and can implement new versions of the updater as you see fit.
If this project helped you in any way and you feel like buying a broke college kid a cup of coffee
MIT License
Copyright (c) 2017 Alex Epstein
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.