Advertisement
Guest User

Untitled

a guest
Dec 7th, 2010
3,476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.69 KB | None | 0 0
  1. #!/bin/bash
  2. # Copyfuck © 2010 q
  3. #
  4. # This script installs, updates and runs LOIC on Linux.
  5. #
  6. # Supported distributions:
  7. #   * Ubuntu / Debian
  8. #   * Fedora
  9. #
  10. # Usage: bash install_loic.bash <install|update|run>
  11.  
  12. ###COLOURS###
  13.  
  14. txt_bld=$(tput bold)  
  15. bld_red=${txt_bld}$(tput setaf 1)
  16. col_rst=$(tput sgr0)
  17.  
  18. ###GLOBALS###
  19.  
  20. GIT_REPO=https://github.com/NewEraCracker/LOIC.git
  21. GIT_BRANCH=master
  22.  
  23. ###FUNCTIONS###
  24.  
  25. ensure_git() #Checks if git is installed, Tries to install it if not
  26. {
  27.     type -P git &>/dev/null ||
  28.     {
  29.         echo -e "${bld_red}Git not found! Attempting to install...${col_rst}"
  30.         if [ -f /etc/lsb-release ] ; then
  31.             sudo apt-get install git
  32.         elif [ -f /etc/fedora-release ] ; then
  33.             sudo yum install git
  34.                 elif [ -f /etc/debian_version ] ; then
  35.             sudo apt-get install git
  36.         fi
  37.     }
  38. }
  39.  
  40.  
  41. is_loic_git()
  42. {
  43.     [[ -d .git ]] && grep -q LOIC .git/config
  44. }
  45.  
  46.  
  47. is_loic() {
  48.     is_loic_git ||
  49.     {
  50.         [[ -d LOIC ]] && cd LOIC && is_loic_git
  51.     }
  52. }
  53.  
  54. get_loic() {
  55.     ensure_git
  56.     if ! is_loic ; then
  57.         git init
  58.         git clone $GIT_REPO -b $GIT_BRANCH
  59.     fi
  60. }
  61.  
  62. compile_loic() {
  63.     get_loic
  64.     if ! is_loic ; then
  65.         echo -e "${bld_red}Error: You are not in a LOIC repository.${col_rst}"
  66.         exit 1
  67.     else
  68.         if [ -f /etc/lsb-release ] ; then
  69.             echo -e "${bld_red}monodevelop and liblog4net-cil-dev not found! Attempting to install...${col_rst}"
  70.             sudo apt-get install monodevelop liblog4net-cil-dev
  71.         elif [ -f /etc/fedora-release ] ; then
  72.             echo -e "${bld_red}mono-basic, mono-devel, monodevelop and mono-tools not found! Attempting to install...${col_rst}"
  73.             sudo yum install mono-basic mono-devel monodevelop mono-tools
  74.                 elif [ -f /etc/debian_version ] ; then
  75.             echo -e "${bld_red}monodevelop and liblog4net-cil-dev not found! Attempting to install...${col_rst}"
  76.             sudo apt-get install monodevelop liblog4net-cil-dev
  77.         fi
  78.     fi
  79.     mdtool build
  80. }
  81.  
  82. run_loic() {
  83.     is_loic
  84.     if [[ ! -e bin/Debug/LOIC.exe ]] ; then
  85.         compile_loic
  86.     fi
  87.     type -P mono &>/dev/null ||
  88.     {
  89.         echo -e "${bld_red}mono-runtime not found! Attempting to install...${col_rst}"
  90.         if [ -f /etc/lsb-release ] ; then
  91.             sudo apt-get install mono-runtime
  92.         elif [ -f /etc/fedora-release ] ; then
  93.             sudo yum install mono-runtime
  94.                 elif [ -f /etc/debian_version ] ; then
  95.             sudo apt-get install mono-runtime
  96.         fi
  97.     }
  98.     mono bin/Debug/LOIC.exe
  99. }
  100.  
  101. update_loic() {
  102.     ensure_git
  103.     if is_loic ; then
  104.         git pull --rebase
  105.         compile_loic
  106.     else
  107.         echo -e "${bld_red}Error: You are not in a LOIC repository.${col_rst}"
  108.     fi
  109. }
  110.  
  111. case $1 in
  112.     install)
  113.         compile_loic
  114.         ;;
  115.     update)
  116.         update_loic
  117.         ;;
  118.     run)
  119.         run_loic
  120.         ;;
  121.     *)
  122.         echo "Usage: $0 <install|update|run>"
  123.         ;;
  124. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement