From 92014c8a99678ad5facdd51060438db8fe6b5630 Mon Sep 17 00:00:00 2001 From: Whitman Huntley Date: Fri, 28 Sep 2018 14:49:25 -0400 Subject: [PATCH 1/3] wrote a updater --- goaurum | 73 ++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 14 deletions(-) diff --git a/goaurum b/goaurum index d7b508e..b63ef78 100755 --- a/goaurum +++ b/goaurum @@ -2,9 +2,6 @@ # a 300+ line bodge. -# The one line of code that gets updated. -au_latestversion="v1.0.0" - _start() { if [ -z `grep "NAME=\"$1\"" $HOME/.aurumfile` ] ; then echo "$1 not found." ; exit 1 ; fi pid=`ps -eo "pid,ucomm" | grep "[0-9]\s.$1" | perl -pe 's/^[\s]+//g' | perl -pe 's/[\s].+//g'` @@ -50,6 +47,45 @@ _remove() { echo "Successfully removed $1 from the database." } +_update() { + mkdir $HOME/.autmp + cd $HOME/.autmp + if [ ! -z "$2" ] ; then + git clone --branch $2 https://github.com/aurumbot/core.git + else + git clone https://github.com/aurumbot/core.git + fi + if [ "$1" = "--goaurum" ] ; then + mkdir auupdate ; chmod +x auupdate + cat > auupdate << EOF +#!/bin/bash +sleep 5 +rm /usr/local/bin/goaurum +mv ./goaurum /usr/local/bin/goaurum +chmod +x /usr/local/bin/goaurum +EOF + echo "Preparing to update goaurum. Note that this may take a bit" + echo "It also appears to stop the updater, this is normal. Please wait for" + echo "a short while (30 seconds?) for it to update, then try goaurum again." + ./auupdate & + exit 0 + fi + path=`grep "NAME=\"$1\"" $HOME/.aurumfile | perl -pe "s/^NAME=\"$1\":PATH=\"|\"$//g"` + if [ -z "$path" ] ; then + echo "$1 not found." + exit 1 + fi + _stop $1 > /dev/null 2>&1 + rm $path/.$1 + env CGO_ENABLED=1 GO111MODULE=on go build -o $path/.$1 ./main.go + if [ "$?" -ne "0" ] ; then exit 1 ; else echo "Successfully updated $1." ; fi +} + +_goaurumupdatefinalize() { + rm -rf $HOME/.autmp > /dev/null 2>&1 + echo "Updates installed! (I hope)" +} + _list() { name=`grep "^NAME=\".*\"" $HOME/.aurumfile | perl -pe "s/^NAME=\"|\":PATH=\".*\"$//g" ; printf "\n"` echo $name @@ -214,7 +250,7 @@ _install() { echo "$au_name has been compiled. Finishing up." # I'm sorry. - cat > ./dat/cfg/aurum/preferences.json << JsonEnd + cat > ./dat/cfg/aurum/preferences.json << EOF { "clientID": "$au_cid", "secret": "$au_sec", @@ -230,7 +266,7 @@ _install() { "" ] } -JsonEnd +EOF # ok its over. rm -rf ./handler rm go.mod @@ -247,19 +283,27 @@ _help() { printf "\033[1;31mUsage: \033[1;33mgoaurum