From 00efe6b0bf1fc1966a8691ab36ddb66aa2c91bd5 Mon Sep 17 00:00:00 2001 From: Ingwar Wirjawan Date: Mon, 29 Aug 2016 03:27:42 +0800 Subject: [PATCH 1/3] execute setup.sh -u if there is a need to --- run.sh | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/run.sh b/run.sh index c0179885a5..434916b254 100755 --- a/run.sh +++ b/run.sh @@ -3,38 +3,35 @@ pokebotpath=$(cd "$(dirname "$0")"; pwd) auth="" config="" if [ ! -z $1 ]; then -auth=$1 + auth=$1 else -auth="./configs/auth.json" + auth="./configs/auth.json" fi if [ ! -z $2 ]; then -config=$2 + config=$2 else -config="./configs/config.json" + config="./configs/config.json" fi cd $pokebotpath source bin/activate git fetch -a -if [ "1" == $(git branch -vv |grep -c "* dev") ] && [ $(git log --pretty=format:"%h" -1) != $(git log --pretty=format:"%h" -1 origin/dev) ] +if [ "1" == $(git branch -vv |grep -c "* dev") ] && [ $(git log --pretty=format:"%h" -1) != $(git log --pretty=format:"%h" -1 origin/dev) ] || + [ "1" == $(git branch -vv |grep -c "* master") ] && [ $(git log --pretty=format:"%h" -1) != $(git log --pretty=format:"%h" -1 origin/master) ] then -echo "Branch dev have an update. Run ./setup.sh -u to update." -sleep 2 -elif [ "1" == $(git branch -vv |grep -c "* master") ] && [ $(git log --pretty=format:"%h" -1) != $(git log --pretty=format:"%h" -1 origin/master) ] -then -echo "Branch master have an update. Run ./setup.sh -u to update." -sleep 2 + ./setup.sh -u + sleep 2 fi if [ ! -f "$auth" ]; then -echo "There's no auth file. Please use ./setup.sh -a to create one" + echo "There's no auth file. Please use ./setup.sh -a to create one" fi if [ ! -f "$config" ]; then -echo "There's no config file. Please use ./setup.sh -c to create one." + echo "There's no config file. Please use ./setup.sh -c to create one." fi while true do -python pokecli.py -af $auth -cf $config -echo `date`" Pokebot "$*" Stopped." -read -p "Press any button or wait 20 seconds to continue. -" -r -s -n1 -t 20 + python pokecli.py -af $auth -cf $config + echo `date`" Pokebot "$*" Stopped." + read -p "Press any button or wait 20 seconds to continue. + " -r -s -n1 -t 20 done exit 0 From f06996c5029de427ee66598572fca44a16e056a9 Mon Sep 17 00:00:00 2001 From: rawgni Date: Mon, 29 Aug 2016 22:05:08 +0700 Subject: [PATCH 2/3] ask the user whether to run setup.sh -u or not --- run.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/run.sh b/run.sh index 434916b254..7217fe02be 100755 --- a/run.sh +++ b/run.sh @@ -18,8 +18,12 @@ git fetch -a if [ "1" == $(git branch -vv |grep -c "* dev") ] && [ $(git log --pretty=format:"%h" -1) != $(git log --pretty=format:"%h" -1 origin/dev) ] || [ "1" == $(git branch -vv |grep -c "* master") ] && [ $(git log --pretty=format:"%h" -1) != $(git log --pretty=format:"%h" -1 origin/master) ] then - ./setup.sh -u - sleep 2 + read -p "Branch have an update. Run ./setup.sh -u to update? y/n + " do_setup + if [[ $do_setup = "y" || $do_setup = "Y" ]]; + then + ./setup.sh -u + fi fi if [ ! -f "$auth" ]; then echo "There's no auth file. Please use ./setup.sh -a to create one" From a0585614e66020406378c75e3988a1dbc3f4dbb8 Mon Sep 17 00:00:00 2001 From: rawgni Date: Mon, 29 Aug 2016 22:15:02 +0700 Subject: [PATCH 3/3] fix grammatical error --- run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.sh b/run.sh index 7217fe02be..5f8d199bee 100755 --- a/run.sh +++ b/run.sh @@ -18,7 +18,7 @@ git fetch -a if [ "1" == $(git branch -vv |grep -c "* dev") ] && [ $(git log --pretty=format:"%h" -1) != $(git log --pretty=format:"%h" -1 origin/dev) ] || [ "1" == $(git branch -vv |grep -c "* master") ] && [ $(git log --pretty=format:"%h" -1) != $(git log --pretty=format:"%h" -1 origin/master) ] then - read -p "Branch have an update. Run ./setup.sh -u to update? y/n + read -p "Branch has an update. Run ./setup.sh -u to update? y/n " do_setup if [[ $do_setup = "y" || $do_setup = "Y" ]]; then