-
Notifications
You must be signed in to change notification settings - Fork 15
/
setup.sh
executable file
·216 lines (205 loc) · 5.13 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/usr/bin/env bash
#encoding=utf8
pokebotpath=$(cd "$(dirname "$0")"; pwd)
backuppath=$pokebotpath"/backup"
function Pokebotupdate () {
cd $pokebotpath
git pull
git submodule update --init --recursive
git submodule foreach git pull origin master
source bin/activate
pip install -r requirements.txt --upgrade
pip install -r requirements.txt
}
function Pokebotencrypt () {
echo "Start to make encrypt.so."
if [ -x "$(command -v curl)" ]
then
curl -O http://pgoapi.com/pgoencrypt.tar.gz
else
wget http://pgoapi.com/pgoencrypt.tar.gz
fi
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 Pokebotescapestring () {
echo "$1" | sed 's/\//\\\//g' | sed 's/"/\\"/g' # escape slash and double quotes
}
function Pokebotauth () {
cd $pokebotpath
read -p "
-----------------
Auth generator
Enter 1 for Google or 2 for Pokemon Trainer Club (PTC)
-----------------
" auth
read -p "Input E-Mail (Google) or Username(PTC)
" username
read -p "Input Password
" -s password
password=$(Pokebotescapestring $password)
read -p "
Input Location
" location
read -p "Input Google API Key (gmapkey)
" gmapkey
[[ $auth = "2" || $auth = "ptc" ]] && auth="ptc" || auth="google"
sed -e "s/YOUR_USERNAME/$username/g" -e "s/YOUR_PASSWORD/$password/g" \
-e "s/SOME_LOCATION/$location/g" -e "s/GOOGLE_MAPS_API_KEY/$gmapkey/g" \
-e "s/google/$auth/g" configs/auth.json.example > configs/auth.json
echo "Edit ./configs/auth.json to modify auth or location."
}
function Pokebotconfig () {
cd $pokebotpath
read -p "
-----------------
Config Generator
Enter 1 for default, 2 for cluster, 3 for map, 4 for optimizer, 5 for path or 6 pokemon config
-----------------
" cfgoption
[ "$cfgoption" == "1" ] && cfgoption="config.json.example"
[ "$cfgoption" == "2" ] && cfgoption="config.json.cluster.example"
[ "$cfgoption" == "3" ] && cfgoption="config.json.map.example"
[ "$cfgoption" == "4" ] && cfgoption="config.json.optimizer.example"
[ "$cfgoption" == "5" ] && cfgoption="config.json.path.example"
[ "$cfgoption" == "6" ] && cfgoption="config.json.pokemon.example"
cp configs/$cfgoption configs/config.json
echo "Edit ./configs/config.json to modify any other config."
}
function Pokebotinstall () {
cd $pokebotpath
if [ "$(uname -s)" == "Darwin" ]
then
echo "You are on Mac OS"
brew update
brew install --devel protobuf
elif [ $(uname -s) == CYGWIN* ]
then
echo "You are on Cygwin"
if [ !-x "$(command -v apt-cyg)" ]
then
wget http://apt-cyg.googlecode.com/svn/trunk/apt-cyg
chmod +x apt-cyg
mv apt-cyg /usr/local/bin/
fi
apt-cyg install gcc-core make
easy_install pip
elif [ -x "$(command -v apt-get)" ]
then
echo "You are on Debian/Ubuntu"
sudo apt-get update
sudo apt-get -y install python python-pip python-dev gcc make git
elif [ -x "$(command -v yum)" ]
then
echo "You are on CentOS/RedHat"
sudo yum -y install epel-release gcc make
sudo yum -y install python-pip python-devel
elif [ -x "$(command -v pacman)" ]
then
echo "You are on Arch Linux"
sudo pacman -Sy python2 python2-pip gcc make
elif [ -x "$(command -v dnf)" ]
then
echo "You are on Fedora/RHEL"
sudo dnf update
sudo dnf -y install python-pip python-devel gcc make
elif [ -x "$(command -v zypper)" ]
then
echo "You are on Open SUSE"
sudo zypper update
sudo zypper -y install python-pip python-devel gcc make
else
echo "Please check if you have python pip gcc make installed on your device."
echo "Wait 5 seconds to continue or Use ctrl+c to interrupt this shell."
sleep 5
fi
easy_install virtualenv
Pokebotreset
Pokebotupdate
Pokebotencrypt
echo "Install complete. Starting to generate auth.json and config.json."
Pokebotauth
Pokebotconfig
}
function Pokebotreset () {
cd $pokebotpath
git fetch -a
if [ "1" == $(git branch -vv |grep -c "* dev") ]
then
echo "Branch dev resetting."
git reset --hard origin/dev
elif [ "1" == $(git branch -vv |grep -c "* master") ]
then
echo "Branch master resetting."
git reset --hard origin/master
fi
if [ -x "$(command -v python2)" ]
then
virtualenv -p python2 .
else
virtualenv .
fi
Pokebotupdate
}
function Pokebothelp () {
echo "usage:"
echo " -i,--install. Install PokemonGo-Bot."
echo " -b,--backup. Backup config files."
echo " -a,--auth. Easy auth generator."
echo " -c,--config. Easy config generator."
echo " -e,--encrypt. Make encrypt.so."
echo " -r,--reset. Force sync source 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 -p $backuppath
cp -f $pokebotpath/configs/auth*.json $backuppath/
cp -f $pokebotpath/configs/config*.json $backuppath/
cp -f $pokebotpath/configs/*.gpx $backuppath/
cp -f $pokebotpath/configs/path*.json $backuppath/
cp -f $pokebotpath/web/config/userdata.js $backuppath/
echo "Backup complete."
;;
--auth|-a)
Pokebotauth
;;
--config|-c)
Pokebotconfig
;;
--help|-h)
Pokebothelp
;;
*.json)
filename=$*
echo "It's better to use run.sh, not this one."
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
./run.sh ./configs/"$filename"
fi
;;
*)
Pokebothelp
;;
esac
exit 0