#!/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_owner="r-darwish" topgrade_git_repo="topgrade" if [ ! -f "$topgrade_binary" ]; then echo "** topgrade binary missing, installing now" newest_release=$(curl -sL https://api.github.com/repos/$topgrade_git_owner/$topgrade_git_repo/releases/latest | jq -r ".tag_name") echo $newest_release 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 linux_amd64.tar.gz) echo $newest_release_url wget "https://github.com/$topgrade_git_owner/$topgrade_git_repo/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 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" 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