Duclv

bot

Feb 6th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.49 KB | None | 0 0
  1. #!/bin/bash
  2. if [ `ps -e | grep -c botTE.sh` -gt 2 ]; then echo "Already running, i'm killing old process, please run it again!"; killall -9 botTE.sh && exit 1; fi
  3. usage() { echo -e "Usage: $0 [-t <Timer to restart chrome (seconds)>] [-l <Separate traffic exchange links with space delimiter(in quote)>]\nExample: $0 -t 3600 -l http://22hit...\nExample: $0 -t 3600 -l \"http://22hit... http://247webhit... http://...\"" 1>&2; exit 1; }
  4. [ $# -eq 0 ] && usage
  5. while getopts ":ht:l:" arg; do
  6.     case $arg in
  7.         t)
  8.             timer=${OPTARG}
  9.             ;;
  10.         l)
  11.             IFS=' ' read -r -a links <<< ${OPTARG}
  12.             ;;
  13.         h | *)
  14.             usage
  15.             exit 1
  16.             ;;
  17.     esac
  18. done
  19.  
  20. if [ -z "${timer}" ] || [ -z "${links}" ]; then
  21.     usage
  22. fi
  23.  
  24. echo "Checking update Chrome and related package..."
  25. wget --no-check-certificate -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
  26. echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list
  27. apt-get update
  28. apt-get clean
  29. apt-get autoclean
  30. apt-get autoremove
  31. apt-get install -y xvfb gtk2-engines-pixbuf libexif12 libxpm4 libxrender1 libgtk2.0-0 libnss3 libgconf-2-4 x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable xfonts-cyrillic x11-apps google-chrome-stable
  32. dpkg --configure -a
  33. apt-get install -f -y
  34. if [[ `lsb_release -rs` == "12.04" ]]
  35. then
  36.     apt-get install -y defoma x-ttcidfont-conf
  37.     (cd /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType && mkfontdir > fonts.dir)
  38. fi
  39. echo "Downloading chrome user data dir profile..."
  40. wget --no-check-certificate https://raw.githubusercontent.com/duclvz/botTE/master/chromeBotTE.tar.gz -O /root/chromeBotTE.tar.gz
  41. while :
  42. do
  43.     echo "Killing chrome and virtual X display..."
  44.     for element in ${links[@]}
  45.     do
  46.         pkill -9 -o chrome
  47.     done
  48.     killall -9 chrome
  49.     killall -9 Xvfb
  50.     echo "Recreating/extracting chrome user data dir..."
  51.     rm -fr /root/chromeBotTE/
  52.     tar -xf /root/chromeBotTE.tar.gz -C /root/
  53.     echo "Starting virtual X display..."
  54.     Xvfb :1 -screen 1 1024x768x16 -nolisten tcp & disown
  55.     echo "Starting chrome TE viewer..."
  56.     for element in ${links[@]}
  57.     do
  58.         echo "Open link $element"
  59.         DISPLAY=:1.1 google-chrome --no-sandbox --disable-gpu --new-window --user-data-dir="/root/chromeBotTE" --disable-popup-blocking --incognito $element & disown
  60.     done
  61.     sleep ${timer}
  62.     echo "TELog: Restart TE bots"
  63. done
Advertisement
Add Comment
Please, Sign In to add comment