Skip to content

Instantly share code, notes, and snippets.

@rnelson
Created November 26, 2017 13:56
Show Gist options
  • Save rnelson/e2588421f8da2194aa7ffcd4ec293f1c to your computer and use it in GitHub Desktop.
Save rnelson/e2588421f8da2194aa7ffcd4ec293f1c to your computer and use it in GitHub Desktop.
Script to install Tarsnap
#!/bin/bash
set -e
ROOT=/opt/tarsnap
usage() {
echo "usage: $0 <version>"
exit 1
}
if [ $# -ne 1 ]; then
usage
fi
VERSION=$1
SRC=https://www.tarsnap.com/download/tarsnap-autoconf-${VERSION}.tgz
SIG=https://www.tarsnap.com/download/tarsnap-sigs-${VERSION}.asc
BUILDDIR=${ROOT}/build/tarsnap-${VERSION}
INSTALLDIR=${ROOT}/tarsnap/tarsnap-${VERSION}
mkdir -p ${ROOT}/archives
mkdir -p ${ROOT}/build
mkdir -p ${ROOT}/tarsnap
mkdir -p ${BUILDDIR}
echo "Downloading source code and signature"
wget -a ${BUILDDIR}/wget.log -O ${ROOT}/archives/tarsnap-autoconf-${VERSION}.tar $SRC
wget -a ${BUILDDIR}/wget.log -O ${ROOT}/archives/tarsnap-sigs-${VERSION}.asc $SIG
echo "Verifying source signature"
(cd ${ROOT}/archives && gpg --verify tarsnap-sigs-${VERSION}.asc >${BUILDDIR}/gpg.log)
echo "Extracting source code"
(cd ${ROOT}/build && tar -xf ${ROOT}/archives/tarsnap-autoconf-${VERSION}.tar >${BUILDDIR}/tar.log)
echo "Building Tarsnap ${VERSION}"
(cd ${ROOT}/build/tarsnap-autoconf-${VERSION} && ./configure --prefix=${INSTALLDIR} >${BUILDDIR}/build.log)
(cd ${ROOT}/build/tarsnap-autoconf-${VERSION} && make >>${BUILDDIR}/build.log && make install >>${BUILDDIR}/build.log)
ln -s ${INSTALLDIR} ${ROOT}/tarsnap/latest
echo ""
echo "Tarsnap ${VERSION} is now installed at ${ROOT}/tarsnap/tarsnap-${VERSION}."
echo " ${ROOT}/tarsnap/latest -> ${ROOT}/tarsnap/tarsnap-${VERSION}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment