Skip to content

Instantly share code, notes, and snippets.

@dhensby
Last active May 19, 2020 02:29
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhensby/6371274 to your computer and use it in GitHub Desktop.
Save dhensby/6371274 to your computer and use it in GitHub Desktop.
A script to install tarsnap automatically on Fedora/CentOS/RHEL
#!/bin/bash
# To do:
# - Force install (regardless of installed tarsnap version) via flag
# - Set version via flag
# - Set TMP_DIR via flag
# - Skip software insall via flag
# - Check signature automatically
VERSION=1.0.37
TMP_DIR=/tmp/tarsnap
REMOVE_DIR=false
if [ -e /usr/local/bin/tarsnap ]; then
TARSNAP_VER=`/usr/local/bin/tarsnap --version`
if [ "$TARSNAP_VER" == "tarsnap $VERSION" ]; then
echo "Quitting because tarsnap already installed"
exit
else
echo "Upgrading Tarsnap"
fi
fi
# A list of the software we need to install
declare -a Software=('gpg2' 'wget' 'gcc' 'openssl-devel' 'zlib-devel' 'e2fsprogs-devel')
# Install the software using yum
echo "Installing required software"
yum -q -y install ${Software[@]}
echo "Checking for temp dir"
if [ ! -d $TMP_DIR ]; then
echo "No tmp dir, creating it"
mkdir $TMP_DIR
REMOVE_DIR=true
fi
# wget the latest file
echo "Fetching tar of tarsnap files"
wget -qO $TMP_DIR/tarsnap.tgz https://www.tarsnap.com/download/tarsnap-autoconf-$VERSION.tgz
echo "Fetching tarsnap signature"
wget -qO $TMP_DIR/tarsnap.asc https://www.tarsnap.com/download/tarsnap-sigs-$VERSION.asc
echo "Fetching tarsnap signing key"
wget -qO $TMP_DIR/tarsnap-signing-key.asc https://www.tarsnap.com/tarsnap-signing-key.asc
# Verify the sigs
#gpg2 -qd $TMP_DIR/tarsnap.asc
echo "Extracting tar"
tar -xf $TMP_DIR/tarsnap.tgz -C $TMP_DIR
echo "Running ./configure"
$TMP_DIR/tarsnap-autoconf-$VERSION/configure
make -s -I $TMP_DIR/tarsnap-autoconf-$VERSION all install clean
if [ $REMOVE_DIR ]; then
echo "Trashing tmp dir"
rm -rf $TMP_DIR
fi
echo "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment