From 8164fff194303bcee02fa8452b3a6f584ede72a2 Mon Sep 17 00:00:00 2001 From: BrendanTCC Date: Fri, 27 Aug 2021 11:48:21 +1000 Subject: [PATCH] more works on wpset-update. --- wpset | 10 +++++++ wpset-update | 85 +++++++++++++++++++++++++++++++--------------------- 2 files changed, 61 insertions(+), 34 deletions(-) diff --git a/wpset b/wpset index fbf9bd9..3cdbbf7 100755 --- a/wpset +++ b/wpset @@ -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 diff --git a/wpset-update b/wpset-update index 0b37fed..6fa4f6a 100644 --- a/wpset-update +++ b/wpset-update @@ -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." \ No newline at end of file