diff --git a/wpset b/wpset index 8d80f1d..fab4629 100755 --- a/wpset +++ b/wpset @@ -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 diff --git a/wpset-update b/wpset-update index 6a269c8..0b37fed 100644 --- a/wpset-update +++ b/wpset-update @@ -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