template_setup/02-topgrade.sh
deathbybandaid 838ec62d9a test
2022-03-08 08:52:37 -05:00

45 lines
1.4 KiB
Bash

#!/bin/bash
echo "Checking Topgrade Situation"
## Script Location
# SCRIPTDIR=$(dirname $0)
echo "Checking for topgrade directory"
topgrade_install_directory="/opt/topgrade"
if [ ! -d "$topgrade_install_directory" ]; then
echo "creating topgrade installation directory"
mkdir $topgrade_install_directory
fi
echo "checking for topgrade binary"
topgrade_binary="/opt/topgrade/topgrade"
topgrade_tar="/opt/topgrade/topgrade.tar.gz"
topgrade_git_user="r-darwish"
topgrade_git_repo="topgrade"
if [ ! -f "$topgrade_binary" ]; then
echo "topgrade binary missing, installing now"
curl -s -L "https://github.com/$topgrade_git_user/$topgrade_git_repo/releases/latest" | egrep -o '/$topgrade_git_user/$topgrade_git_repo/releases/download/[0-9]*/[0-9]*-x86_64-unknown-linux-gnu.tar.gz' | wget --base=http://github.com/ -i - -O "$topgrade_tar"
tar -xvf $topgrade_tar -C $topgrade_install_directory
fi
if [ ! -f "$topgrade_binary" ]; then
echo "topgrade nor present at $topgrade_binary"
fi
echo "checking for topgrade confs"
custom_topgrade_confs_path="/etc/topgrade"
custom_topgrade_confs_git="https://git.deathbybandaid.net/deathbybandaid/topgrade.git"
if [ ! -d "$custom_topgrade_confs_path" ]; then
echo "Installing topgrade configs"
git clone --quiet $custom_topgrade_confs_git $custom_topgrade_confs_path
else
git -C $custom_topgrade_confs_git pull
fi
## Update
if [ -f "$topgrade_binary" ]; then
echo "Running topgrade"
$topgrade_binary
fi