-
Notifications
You must be signed in to change notification settings - Fork 0
/
getborg
executable file
·39 lines (31 loc) · 1.23 KB
/
getborg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
# getborg - Get borgbackup for Pi (armv7l) or PC (x86_64)
# Required: wget sudo coreutils(mktemp rm mv chmod hash)
# For the latest version, see: https://borg.bauerj.eu or
# https://github.com/borgbackup/borg/releases
[[ $- = *i* ]] && echo "Don't source, but run like: bash $BASH_SOURCE" &&
return 1
# Install location for borg binary
bin=/usr/local/bin # Will override /usr/bin for the Ubuntu repo version
urlpi='https://dl.bintray.com/borg-binary-builder/borg-binaries/'
urlpc='https://github.com/borgbackup/borg/releases'
pi='armv7l' pc='x86_64' arch=$(uname -m)
case $arch in
$pi) url=$(wget -qO- $urlpi |grep armv6 |tail -1 |egrep -o '>[^<]+')
url=$urlpi${url:1: -4} ;;
$pc) url=$(wget -qO- $urlpc |grep linux64 |head -1| grep -o '/download[^"]*')
url="https://github.com/borgbackup/borg/releases$url" ;;
*) echo "Unknown hardware: $arch"
exit 2
esac
tmp=$(mktemp -d --tmpdir=$TMPDIR)
! wget -qO "$tmp/borg" $url && echo "Problem downloading $url" && exit 3
[[ -x $bin/borg ]] && borgv=$("$bin/borg" -V) &&
sudo mv -- "$bin/borg" "$bin/${borgv// /-}"
sudo mv -- "$tmp/borg" "$bin"
rm -rf -- "$tmp"
sudo chmod +x -- "$bin/borg"
sudo chown root:root -- "$bin/borg"
hash -r
echo "Borg version: $(borg -V)"
exit 0