more works on wpset-update.

This commit is contained in:
Brendan Webb 2021-08-27 11:48:21 +10:00
parent fc0aca957f
commit 8164fff194
2 changed files with 61 additions and 34 deletions

10
wpset
View File

@ -6,6 +6,16 @@ source $CONF
source /etc/wpdl/parse
# updater
if [ "$1" = "-u" ]; then
# setting USER variable
USER=$(logname)
# root check
ROOT=$(whoami)
if [ "$ROOT" != "root" ]; then
echo "ERR_ROOT_PRIVS_REQUIRE"
echo "(try re-running this script with sudo.)"
exit
fi
# contact tildegit to check for a new release
parse
# compare versions

View File

@ -1,41 +1,58 @@
#!/bin/bash
function process() {
# install the update
mv wpset /bin/wpset
chmod +x /bin/wpset
mv parse /etc/wpdl/parse
chmod +x /etc/wpdl/parse
cd /home/$USER/
rm -rf brendotools-wallman/
echo "done."
WPSET_LOCALVER=$(wpset -v)
if [ "$WPSET_LOCALVER" == "$WPSET_REMOTEVER" ]; then
echo "success! wpset version updated to $WPSET_LOCALVER."
else
echo "something's gone wrong. wpset version is '$WPSET_LOCALVER' when it should be $WPSET_REMOTEVER.\
try manually moving the file and running wpset -v."
fi
fi
exit
}
# root check
ROOT=$(whoami)
if [ "$ROOT" != "root" ]; then
sudo bash wpset-update process
exit
fi
if [ "$1" == "process" ]; then
process
fi
# contact tildegit to see if there's a new release
WPSET_REL=$(mktemp /tmp/wpset-releases-XXXXX.json)
curl -s https://tildegit.org/api/v1/repos/BrendanTCC/brendotools-wallman/releases -o $WPSET_REL
DOWNLOAD_VERSION=$(cat $WPSET_REL | jq .[0].tag_name | sed s/\"//g)
DOWNLOAD_URL=$(cat $WPSET_REL | jq .[0].assets[0].browser_download_url | sed s/\"//g)
DOWNLOAD_FNAME=$(cat $WPSET_REL | jq .[0].assets[0].name | sed s/\"//g)
rm $WPSET_REL
# other important shit
CONF="/home/$USER/.config/wpdl.conf"
source $CONF
WPSET_REMOTEVER="0.1-rev83"
WPSET_LOCALVER=$(wpset -v)
clear
if [ "$WPSET_REMOTEVER" == "$WPSET_LOCALVER" ]; then
echo "no updates to install, latest version already installed"
exit
cd /home/$USER/
FOLDER_CHECK=$(ls | grep brendotools-wallman)
if [ "$FOLDER_CHECK" != "" ]; then
rm -rf brendotools-wallman*
fi
git clone https://tildegit.org/BrendanTCC/brendotools-wallman/
cd brendotools-wallman
source parse
parse
git checkout tags/$DOWNLOAD_VERSION
# set the version because GOOD GOD I'M A LAZY CUNT
echo wpset | sed "s/VERSION\=\"\"/VERSION\=\"$DOWNLOAD_VERSION\""
# setting USER variable
USER=$(logname)
# root check
ROOT=$(whoami)
if [ "$ROOT" != "root" ]; then
sudo bash /home/$USER/brendotools-wallman/wpset-update process
else
PASSWD=$(pass system/sudo)
# The Parsed (and updater)
curl -s $DOWNLOAD_URL -o $DOWNLOAD_FNAME
unzip $DOWNLOAD_FNAME -d /home/$USER/$DOWNLOAD_FOLDER
cd /home/$USER/$DOWNLOAD_FOLDER
chmod +x /home/$USER/$DOWNLOAD_FOLDER/brendotools-wallman/wpset-setup
echo "sudo privileges are required to continue. enter your password."
sudo mv wpset /bin/wpset
sudo chmod +x /bin/wpset
sleep 1
echo "wpset should have successfully updated."
WPSET_LOCALVER=$(wpset -v)
echo "wpset version is now $WPSET_LOCALVER."
process
fi
rm $WPSET_REL
echo "wpset-update is now deprecated. it's now built directly into wpset."