49 lines
1.7 KiB
Bash
49 lines
1.7 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"
|
|
wget "https://github.com/r-darwish/topgrade/releases/download/v8.2.0/topgrade-v8.2.0-x86_64-unknown-linux-gnu.tar.gz" -O "$topgrade_tar"
|
|
# 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
|
|
else
|
|
echo "** topgrade binary exists"
|
|
fi
|
|
if [ ! -f "$topgrade_binary" ]; then
|
|
echo "** topgrade binary not 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
|
|
echo "** Updating topgrade configs"
|
|
git -C $custom_topgrade_confs_path pull
|
|
fi
|
|
|
|
|
|
## Update
|
|
if [ -f "$topgrade_binary" ]; then
|
|
echo "* Running topgrade"
|
|
$topgrade_binary
|
|
fi
|