Guest User

Untitled

a guest
Dec 10th, 2010
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 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/arch-release ] ; then
  31. sudo pacman -Sy git
  32. elif [ -f /etc/lsb-release ] ; then
  33. sudo apt-get install git
  34. elif [ -f /etc/fedora-release ] ; then
  35. sudo yum install git
  36. elif [ -f /etc/debian_version ] ; then
  37. sudo apt-get install git
  38. fi
  39. }
  40. }
  41.  
  42.  
  43. is_loic_git()
  44. {
  45. [[ -d .git ]] && grep -q LOIC .git/config
  46. }
  47.  
  48.  
  49. is_loic() {
  50. is_loic_git ||
  51. {
  52. [[ -d LOIC ]] && cd LOIC && is_loic_git
  53. }
  54. }
  55.  
  56. get_loic() {
  57. ensure_git
  58. if ! is_loic ; then
  59. git init
  60. git clone $GIT_REPO -b $GIT_BRANCH
  61. fi
  62. }
  63.  
  64. compile_loic() {
  65. get_loic
  66. if ! is_loic ; then
  67. echo -e "${bld_red}Error: You are not in a LOIC repository.${col_rst}"
  68. exit 1
  69. else
  70. type -P mono &>/dev/null ||
  71. {
  72. if [ -f /etc/arch-release ] ; then
  73. echo -e "${bld_red}mono not found! Attempting to install...${col_rst}"
  74. sudo pacman -Sy mono
  75. elif [ -f /etc/lsb-release ] ; then
  76. echo -e "${bld_red}monodevelop and liblog4net-cil-dev not found! Attempting to install...${col_rst}"
  77. sudo apt-get install monodevelop liblog4net-cil-dev
  78. elif [ -f /etc/fedora-release ] ; then
  79. echo -e "${bld_red}mono-basic, mono-devel, monodevelop and mono-tools not found! Attempting to install...${col_rst}"
  80. sudo yum install mono-basic mono-devel monodevelop mono-tools
  81. elif [ -f /etc/debian_version ] ; then
  82. echo -e "${bld_red}monodevelop and liblog4net-cil-dev not found! Attempting to install...${col_rst}"
  83. sudo apt-get install monodevelop liblog4net-cil-dev
  84. fi
  85. }
  86. if [ -f /etc/arch-release ] ; then
  87. if ! monodevelop -h &>/dev/null ; then
  88. echo -e "${bld_red}monodevelop not found! Attempting to install...${col_rst}"
  89. sudo pacman -Sy monodevelop
  90. fi
  91. fi
  92. fi
  93. mdtool build
  94. }
  95.  
  96. run_loic() {
  97. is_loic
  98. if [[ ! -e bin/Debug/LOIC.exe ]] ; then
  99. compile_loic
  100. fi
  101. type -P mono &>/dev/null ||
  102. {
  103. echo -e "${bld_red}mono-runtime not found! Attempting to install...${col_rst}"
  104. if [ -f /etc/arch-release ] ; then
  105. sudo pacman -Sy mono
  106. elif [ -f /etc/lsb-release ] ; then
  107. sudo apt-get install mono-runtime
  108. elif [ -f /etc/fedora-release ] ; then
  109. sudo yum install mono-runtime
  110. elif [ -f /etc/debian_version ] ; then
  111. sudo apt-get install mono-runtime
  112. fi
  113. }
  114. mono bin/Debug/LOIC.exe
  115. }
  116.  
  117. update_loic() {
  118. ensure_git
  119. if is_loic ; then
  120. git pull --rebase
  121. compile_loic
  122. else
  123. echo -e "${bld_red}Error: You are not in a LOIC repository.${col_rst}"
  124. fi
  125. }
  126.  
  127. case $1 in
  128. install)
  129. compile_loic
  130. ;;
  131. update)
  132. update_loic
  133. ;;
  134. run)
  135. run_loic
  136. ;;
  137. *)
  138. echo "Usage: $0 <install|update|run>"
  139. ;;
  140. esac
Advertisement
Add Comment
Please, Sign In to add comment