mirror of
https://github.com/lloeki/rsync-backup.git
synced 2025-12-06 01:34:39 +01:00
Add crude updater
This commit is contained in:
parent
ef07b8e57b
commit
832d8ab8c4
1 changed files with 14 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue