switch to having the updater directly in wpset

This commit is contained in:
Brendan Webb 2021-08-24 12:01:36 +10:00
parent 6f5339e0de
commit ce2790124d
2 changed files with 35 additions and 8 deletions

31
wpset
View File

@ -1,13 +1,40 @@
#!/bin/bash
# WPDL
VERSION="0.1-rev82"
VERSION="0.1-rev83"
CONF="/home/$USER/.config/wpdl.conf"
source $CONF
# updater
if [ "$1" = "-u" ]; then
curl -s https://assets.brendo.org/wpset/update | bash
# 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
# compare versions
WPSET_REMOTEVER=$(echo "$DOWNLOAD_VERSION")
WPSET_LOCALVER=$(wpset -v)
if [ "$WPSET_REMOTEVER" == "$WPSET_LOCALVER" ]; then
# tell user that there's nothing to do
echo "you are already running the latest available version of wallman."
exit
else
# download the update
cd /home/$USER/
wget $DOWNLOAD_URL -o $DOWNLOAD_FNAME
unzip $DOWNLOAD_FNAME
cd brendotools-wallman
mv wpset /bin/wpset
chmod +x /bin/wpset
cd /home/$USER/
rm -rf brendotools-wallman/
echo "done."
fi
# version

View File

@ -1,18 +1,17 @@
#!/bin/bash
# this file will reside at https://assets.brendo.org/wpset/update
# parse json
# 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)
DOWNLOAD_FOLDER=$(echo "$DOWNLOAD_FNAME" | sed s/\.zip//)
rm $WPSET_REL
# other important shit
CONF="/home/$USER/.config/wpdl.conf"
source $CONF
WPSET_REMOTEVER=$(echo "$DOWNLOAD_VERSION")
WPSET_REMOTEVER="0.1-rev83"
WPSET_LOCALVER=$(wpset -v)
clear
@ -30,11 +29,12 @@ 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 /home/$USER/$DOWNLOAD_FOLDER/brendotools-wallman/wpset-setup -u
sudo mv wpset /bin/wpset
sudo chmod +x /bin/wpset
sleep 1
echo "wpset updated."
echo "wpset should have successfully updated."
WPSET_LOCALVER=$(wpset -v)
echo "wpset version is now $WPSET_LOCALVER."
fi