49 lines
1.8 KiB
Bash
49 lines
1.8 KiB
Bash
#!/bin/bash
|
|
echo "Checking Topgrade Situation"
|
|
|
|
## Script Location
|
|
SCRIPTDIR=$(dirname $0)
|
|
source "$SCRIPTDIR/common/functions.sh"
|
|
|
|
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_owner="r-darwish"
|
|
topgrade_git_repo="topgrade"
|
|
if [ ! -f "$topgrade_binary" ]; then
|
|
echo "** topgrade binary missing, installing now"
|
|
newest_release_url=$(curl -sL https://api.github.com/repos/$topgrade_git_owner/$topgrade_git_repo/releases/latest | jq -r ".assets[].browser_download_url" | grep x86_64-unknown-linux-gnu.tar.gz)
|
|
wget $newest_release_url -q -O "$topgrade_tar"
|
|
tar -xvf $topgrade_tar -C $topgrade_install_directory
|
|
rm $topgrade_tar
|
|
chmod +x $topgrade_binary
|
|
else
|
|
echo "** topgrade binary exists"
|
|
fi
|
|
if [ ! -f "$topgrade_binary" ]; then
|
|
echo "** topgrade binary not present at $topgrade_binary"
|
|
else
|
|
current_version=$($topgrade_binary --version | sed 's/[A-Za-z]*//g')
|
|
echo "** Locally installed topgrade version: $current_version"
|
|
newest_release=$(curl -sL https://api.github.com/repos/$topgrade_git_owner/$topgrade_git_repo/releases/latest | jq -r ".tag_name" | sed 's/[A-Za-z]*//g')
|
|
echo "** Online topgrade version: $newest_release"
|
|
fi
|
|
|
|
echo "checking for topgrade confs"
|
|
custom_topgrade_confs_path="/etc/topgrade"
|
|
custom_topgrade_confs_git="https://git.deathbybandaid.net/deathbybandaid/topgrade.git"
|
|
git_update "topgrade" "$custom_topgrade_confs_path" "$custom_topgrade_confs_git"
|
|
|
|
## Update
|
|
if [ -f "$topgrade_binary" ]; then
|
|
echo "* Running topgrade"
|
|
$topgrade_binary
|
|
fi
|