Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Powerful setup.sh #3263

Merged
merged 11 commits into from
Aug 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is still needed for multiple configurations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I will revert it.

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