Skip to content

Commit

Permalink
Powerful setup.sh (PokemonGoF#3263)
Browse files Browse the repository at this point in the history
* Rewrite run.sh

Very powerful run.sh with lots of function.
1.install(make .so)
2.update
3.config generator
4.config backup
5.run loop make it never down

It should run like 
run.sh *.json or other opinion. 
See -help.

* Update run.sh

* Update run.sh

OK problem solved

* Delete setup.py

* Rename run.sh to setup.sh

* Create run.sh

* Update setup.sh

* Update install.sh

* Update setup.sh

* Update run.sh

* Update setup.sh

Some small fix.
  • Loading branch information
simonsmh authored and thebigjc committed Aug 9, 2016
1 parent 183711f commit 5ce175a
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 50 deletions.
79 changes: 61 additions & 18 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,62 @@
#!/usr/bin/env bash

# Setup Python virtualenv
echo "Setting up Python virtualenv..."
eval "virtualenv ."
eval "source bin/activate"
echo "Python virtualenv setup successfully."

# Install pip requirements
echo "Installing pip requirements..."
eval "pip install -r requirements.txt"
echo "Installed pip requirements."
echo "Installing and updating git submodules..."

# Install git submodules
eval "cd ./web && git submodule init && cd .."
eval "git submodule update"
echo "Done."
echo "Please create and setup configs/config.json. Then, run 'python pokecli.py --config ./configs/config.json' or './run.sh' on Mac/Linux"
pokebotpath=$(pwd)
cd $pokebotpath
if [ -f /etc/debian_version ]
then
echo "You are on Debian/Ubuntu"
sudo apt-get update
sudo apt-get -y install python python-pip python-dev build-essential git python-protobuf virtualenv
elif [ -f /etc/redhat-release ]
then
echo "You are on CentOS/RedHat"
sudo yum -y install epel-release
sudo yum -y install python-pip
elif [ "$(uname -s)" == "Darwin" ]
then
echo "You are on Mac os"
sudo brew update
sudo brew install --devel protobuf
else
echo "Nothing happend."
fi
pip install virtualenv
cd $pokebotpath
git pull
git submodule init
git submodule foreach git pull origin master
virtualenv .
source bin/activate
pip install -r requirements.txt
echo "Start to make encrypt.so"
wget http://pgoapi.com/pgoencrypt.tar.gz
tar -xf pgoencrypt.tar.gz
cd pgoencrypt/src/
make
mv libencrypt.so $pokebotpath/encrypt.so
cd ../..
rm -rf pgoencrypt.tar.gz
rm -rf pgoencrypt
echo "Install complete."
cd $pokebotpath
read -p "1.google 2.ptc
" auth
read -p "Input username
" username
read -p "Input password
" -s password
read -p "
Input location
" location
read -p "Input gmapkey
" gmapkey
cp configs/config.json.example configs/config.json
if [ "$auth" = "2" ]
then
sed -i "s/google/ptc/g" configs/config.json
fi
sed -i "s/YOUR_USERNAME/$username/g" configs/config.json
sed -i "s/YOUR_PASSWORD/$password/g" configs/config.json
sed -i "s/SOME_LOCATION/$location/g" configs/config.json
sed -i "s/GOOGLE_MAPS_API_KEY/$gmapkey/g" configs/config.json
echo "Edit configs/config.json to modify any other config. Use run.sh to run."
exit 0
33 changes: 14 additions & 19 deletions run.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
#!/usr/bin/env bash

# Starts PokemonGo-Bot
config=""

pokebotpath=$(pwd)
filename=""
if [ ! -z $1 ]; then
config=$1
filename=$1
else
config="./configs/config.json"
if [ ! -f ${config} ]; then
echo -e "There's no ./configs/config.json file"
echo -e "Please create one or use another config file"
echo -e "./run.sh [path/to/config/file]"
exit 1
fi
filename="./configs/config.json"
if [ ! -f "$filename" ]
then
echo "There's no "$filename" file. use setup.sh -config to creat one."
fi
fi

while [ true ]
while true
do
echo "###############################################"
echo "##Exit two times with [Ctl+C] to end the loop##"
echo "###############################################"
sleep 1
python pokecli.py --config ${config}
sleep "10"
cd $pokebotpath
python pokecli.py -cf $filename
read -p "Press any button or wait 20 seconds." -r -s -n1 -t 20
echo `date`"Pokebot"$*" Stopped."
done
exit 0
13 changes: 0 additions & 13 deletions setup.py

This file was deleted.

135 changes: 135 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#!/usr/bin/env bash
pokebotpath=$(pwd)
backuppath=$(pwd)"/backup"

function Pokebotupdate () {
cd $pokebotpath
git pull
git submodule init
git submodule foreach git pull origin master
virtualenv .
source bin/activate
pip install -r requirements.txt
}

function Pokebotencrypt () {
echo "Start to make encrypt.so"
wget http://pgoapi.com/pgoencrypt.tar.gz
tar -xf pgoencrypt.tar.gz
cd pgoencrypt/src/
make
mv libencrypt.so $pokebotpath/encrypt.so
cd ../..
rm -rf pgoencrypt.tar.gz
rm -rf pgoencrypt
}

function Pokebotconfig () {
cd $pokebotpath
read -p "1.google 2.ptc
" auth
read -p "Input username
" username
read -p "Input password
" -s password
read -p "
Input location
" location
read -p "Input gmapkey
" gmapkey
cp configs/config.json.example configs/config.json
if [ "$auth" = "2" ]
then
sed -i "s/google/ptc/g" configs/config.json
fi
sed -i "s/YOUR_USERNAME/$username/g" configs/config.json
sed -i "s/YOUR_PASSWORD/$password/g" configs/config.json
sed -i "s/SOME_LOCATION/$location/g" configs/config.json
sed -i "s/GOOGLE_MAPS_API_KEY/$gmapkey/g" configs/config.json
echo "Edit configs/config.json to modify any other config."
}

function Pokebotinstall () {
cd $pokebotpath
if [ -f /etc/debian_version ]
then
echo "You are on Debian/Ubuntu"
sudo apt-get update
sudo apt-get -y install python python-pip python-dev build-essential git python-protobuf virtualenv
elif [ -f /etc/redhat-release ]
then
echo "You are on CentOS/RedHat"
sudo yum -y install epel-release
sudo yum -y install python-pip
elif [ "$(uname -s)" == "Darwin" ]
then
echo "You are on Mac os"
sudo brew update
sudo brew install --devel protobuf
else
echo "Nothing happend."
fi
sudo pip install virtualenv
Pokebotupdate
Pokebotencrypt
echo "Install complete."
Pokebotconfig
}

function Pokebotreset () {
cd $pokebotpath
git fetch --all
git reset --hard origin/dev
Pokebotupdate
}

function Pokebothelp () {
echo "usage:"
echo " -i,--install. Install PokemonGo-Bot."
echo " -b,--backup. Backup config files."
echo " -c,--config. Easy config generator."
echo " -e,--encrypt. Make encrypt.so."
echo " -r,--reset. Force sync dev branch."
echo " -u,--update. Command git pull to update."
}

case $* in
--install|-i)
Pokebotinstall
;;
--encrypt|-e)
Pokebotencrypt
;;
--reset|-r)
Pokebotreset
;;
--update|-u)
Pokebotupdate
;;
--backup|-b)
mkdir $backuppath
cp -f $pokebotpath/configs/config*.json $backuppath/
cp -f $pokebotpath/web/config/userdata.js $backuppath/
echo "Backup complete"
;;
--config|-c)
Pokebotconfig
;;
--help|-h)
Pokebothelp
;;
*.json)
filename=$*
cd $pokebotpath
if [ ! -f ./configs/"$filename" ]
then
echo "There's no ./configs/"$filename" file. It's better to use run.sh not this one."
else
Pokebotrun
fi
;;
*)
Pokebothelp
;;
esac
exit 0

0 comments on commit 5ce175a

Please sign in to comment.