Add crude updater

This commit is contained in:
Loic Nageleisen 2021-07-13 20:15:13 +02:00
parent ef07b8e57b
commit 832d8ab8c4
Signed by: lloeki
GPG key ID: 971B4D9F125CD31E

View file

@ -12,6 +12,20 @@ set -o pipefail
# TODO: lock, and unlock on trap exit
# TODO: non-darwin compatibility
update() {
this="$(basename "${1}")"
url="${2}"
tempfile="$(mktemp "/tmp/${this}".XXXXXX)"
curl -L "${url}" > "${tempfile}"
cat "${tempfile}" > "${this}"
rm "${tempfile}"
exit
}
if [[ ${1:-} = '-u' ]]; then
update "${BASH_SOURCE[0]}" 'https://raw.githubusercontent.com/lloeki/rsync-backup/master/rsync-backup.sh'
fi
if [[ -z "${HOME}" ]]; then
echo "error: \$HOME unset" 1>&2
exit 1