install.sh 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. #!/bin/bash
  2. module="$(pwd)/module"
  3. rm -rf ${module}
  4. wget -O ${module} "https://raw.githubusercontent.com/rudi9999/Herramientas/main/module/module" &>/dev/null
  5. [[ ! -e ${module} ]] && exit
  6. chmod +x ${module} &>/dev/null
  7. source ${module}
  8. CTRL_C(){
  9. rm -rf ${module}; exit
  10. }
  11. trap "CTRL_C" INT TERM EXIT
  12. ADMRufu="/etc/ADMRufu" && [[ ! -d ${ADMRufu} ]] && mkdir ${ADMRufu}
  13. ADM_inst="${ADMRufu}/install" && [[ ! -d ${ADM_inst} ]] && mkdir ${ADM_inst}
  14. SCPinstal="$HOME/install"
  15. rm -rf /etc/localtime &>/dev/null
  16. ln -s /usr/share/zoneinfo/America/Argentina/Tucuman /etc/localtime &>/dev/null
  17. rm $(pwd)/$0 &> /dev/null
  18. stop_install(){
  19. title "INSTALACION CANCELADA"
  20. exit
  21. }
  22. time_reboot(){
  23. print_center -ama "REINICIANDO VPS EN $1 SEGUNDOS"
  24. REBOOT_TIMEOUT="$1"
  25. while [ $REBOOT_TIMEOUT -gt 0 ]; do
  26. print_center -ne "-$REBOOT_TIMEOUT-\r"
  27. sleep 1
  28. : $((REBOOT_TIMEOUT--))
  29. done
  30. reboot
  31. }
  32. os_system(){
  33. system=$(cat -n /etc/issue |grep 1 |cut -d ' ' -f6,7,8 |sed 's/1//' |sed 's/ //')
  34. distro=$(echo "$system"|awk '{print $1}')
  35. case $distro in
  36. Debian)vercion=$(echo $system|awk '{print $3}'|cut -d '.' -f1);;
  37. Ubuntu)vercion=$(echo $system|awk '{print $2}'|cut -d '.' -f1,2);;
  38. esac
  39. }
  40. repo(){
  41. link="https://raw.githubusercontent.com/rudi9999/ADMRufu/main/Repositorios/$1.list"
  42. case $1 in
  43. 8|9|10|11|16.04|18.04|20.04|20.10|21.04|21.10|22.04)wget -O /etc/apt/sources.list ${link} &>/dev/null;;
  44. esac
  45. }
  46. dependencias(){
  47. soft="sudo bsdmainutils zip unzip ufw curl python python3 python3-pip openssl screen cron iptables lsof nano at mlocate gawk grep bc jq curl npm nodejs socat netcat netcat-traditional net-tools cowsay figlet lolcat"
  48. for i in $soft; do
  49. leng="${#i}"
  50. puntos=$(( 21 - $leng))
  51. pts="."
  52. for (( a = 0; a < $puntos; a++ )); do
  53. pts+="."
  54. done
  55. msg -nazu " instalando $i$(msg -ama "$pts")"
  56. if apt install $i -y &>/dev/null ; then
  57. msg -verd "INSTALL"
  58. else
  59. msg -verm2 "FAIL"
  60. sleep 2
  61. tput cuu1 && tput dl1
  62. print_center -ama "aplicando fix a $i"
  63. dpkg --configure -a &>/dev/null
  64. sleep 2
  65. tput cuu1 && tput dl1
  66. msg -nazu " instalando $i$(msg -ama "$pts")"
  67. if apt install $i -y &>/dev/null ; then
  68. msg -verd "INSTALL"
  69. else
  70. msg -verm2 "FAIL"
  71. fi
  72. fi
  73. done
  74. }
  75. ofus(){
  76. unset server
  77. server=$(echo ${txt_ofuscatw}|cut -d':' -f1)
  78. unset txtofus
  79. number=$(expr length $1)
  80. for((i=1; i<$number+1; i++)); do
  81. txt[$i]=$(echo "$1" | cut -b $i)
  82. case ${txt[$i]} in
  83. ".")txt[$i]="*";;
  84. "*")txt[$i]=".";;
  85. "1")txt[$i]="@";;
  86. "@")txt[$i]="1";;
  87. "2")txt[$i]="?";;
  88. "?")txt[$i]="2";;
  89. "4")txt[$i]="%";;
  90. "%")txt[$i]="4";;
  91. "-")txt[$i]="K";;
  92. "K")txt[$i]="-";;
  93. esac
  94. txtofus+="${txt[$i]}"
  95. done
  96. echo "$txtofus" | rev
  97. }
  98. function_verify () {
  99. permited=$(curl -sSL "https://raw.githubusercontent.com/rudi9999/Control/master/Control-IP")
  100. [[ $(echo $permited|grep "${IP}") = "" ]] && {
  101. clear
  102. msg -bar
  103. print_center -verm2 "¡LA IP $(wget -qO- ipv4.icanhazip.com) NO ESTA AUTORIZADA!"
  104. print_center -ama "CONTACTE A @Rufu99"
  105. msg -bar
  106. rm ${ADMRufu}
  107. [[ -e $HOME/lista-arq ]] && rm $HOME/lista-arq
  108. exit
  109. } || {
  110. ### INTALAR VERCION DE SCRIPT
  111. ver=$(curl -sSL "https://raw.githubusercontent.com/rudi9999/ADMRufu/main/vercion")
  112. echo "$ver" > ${ADMRufu}/vercion
  113. }
  114. }
  115. fun_ip(){
  116. MEU_IP=$(ip addr | grep 'inet' | grep -v inet6 | grep -vE '127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -o -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1)
  117. MEU_IP2=$(wget -qO- ipv4.icanhazip.com)
  118. [[ "$MEU_IP" != "$MEU_IP2" ]] && IP="$MEU_IP2" || IP="$MEU_IP"
  119. }
  120. verificar_arq(){
  121. unset ARQ
  122. case $1 in
  123. menu|menu_inst.sh|tool_extras.sh|chekup.sh)ARQ="${ADMRufu}";;
  124. *)ARQ="${ADM_inst}";;
  125. esac
  126. mv -f ${SCPinstal}/$1 ${ARQ}/$1
  127. chmod +x ${ARQ}/$1
  128. }
  129. error_fun(){
  130. msg -bar3
  131. print_center -verm "ERROR de enlace VPS<-->GENERADOR"
  132. msg -bar3
  133. [[ -d ${SCPinstal} ]] && rm -rf ${SCPinstal}
  134. exit
  135. }
  136. post_reboot(){
  137. echo 'wget -O /root/install.sh "https://raw.githubusercontent.com/rudi9999/ADMRufu/main/install.sh"; clear; sleep 2; chmod +x /root/install.sh; /root/install.sh --continue' >> /root/.bashrc
  138. title "INSTALADOR ADMRufu"
  139. print_center -ama "La instalacion continuara\ndespues del reinicio!!!"
  140. msg -bar
  141. }
  142. install_start(){
  143. title "INSTALADOR ADMRufu"
  144. print_center -ama "A continuacion se actualizaran los paquetes\ndel systema. Esto podria tomar tiempo,\ny requerir algunas preguntas\npropias de las actualizaciones."
  145. msg -bar3
  146. msg -ne " Desea continuar? [S/N]: "
  147. read opcion
  148. [[ "$opcion" != @(s|S) ]] && stop_install
  149. title "INSTALADOR ADMRufu"
  150. os_system
  151. repo "${vercion}"
  152. apt update -y; apt upgrade -y
  153. }
  154. install_continue(){
  155. os_system
  156. title "INSTALADOR ADMRufu"
  157. print_center -ama "$distro $vercion"
  158. print_center -verd "INSTALANDO DEPENDENCIAS"
  159. msg -bar3
  160. dependencias
  161. msg -bar3
  162. print_center -azu "Removiendo paquetes obsoletos"
  163. apt autoremove -y &>/dev/null
  164. sleep 2
  165. tput cuu1 && tput dl1
  166. print_center -ama "si algunas de las dependencias falla!!!\nal terminar, puede intentar instalar\nla misma manualmente usando el siguiente comando\napt install nom_del_paquete"
  167. enter
  168. }
  169. while :
  170. do
  171. case $1 in
  172. -s|--start)install_start && post_reboot && time_reboot "15";;
  173. -c|--continue)rm /root/install.sh &> /dev/null
  174. sed -i '/Rufu/d' /root/.bashrc
  175. install_continue
  176. break;;
  177. -u|--update)install_start
  178. install_continue
  179. break;;
  180. *)exit;;
  181. esac
  182. done
  183. title "INSTALADOR ADMRufu"
  184. fun_ip
  185. while [[ ! $Key ]]; do
  186. echo -e " $(msg -verm3 "╭╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼[")$(msg -azu "INGRESA TU KEY")$(msg -verm3 "]")"
  187. echo -ne " $(msg -verm3 "╰╼")\033[37;1m>\e[32m\e[1m "
  188. read Key
  189. done
  190. msg -bar3
  191. msg -ne " Verificando Key: "
  192. cd $HOME
  193. wget -O $HOME/lista-arq $(ofus "$Key")/$IP > /dev/null 2>&1 && msg -verd "Key Completa" || {
  194. msg -verm2 "Key Invalida"
  195. msg -bar
  196. [[ -e $HOME/lista-arq ]] && rm $HOME/lista-arq
  197. exit
  198. }
  199. msg -bar3
  200. IP=$(ofus "$Key" | grep -vE '127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -o -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}') && echo "$IP" > /usr/bin/vendor_code
  201. sleep 1s
  202. function_verify
  203. if [[ -e $HOME/lista-arq ]] && [[ ! $(cat $HOME/lista-arq|grep "KEY INVALIDA!") ]]; then
  204. msg -verd " INSTALANDO SCRIPT ADMRufu... $(msg -ama "[Proyect by @Rufu99]")"
  205. REQUEST=$(ofus "$Key"|cut -d'/' -f2)
  206. [[ ! -d ${SCPinstal} ]] && mkdir ${SCPinstal}
  207. msg -nama "Descarga de archivos... "
  208. for arqx in $(cat $HOME/lista-arq); do
  209. wget --no-check-certificate -O ${SCPinstal}/${arqx} ${IP}:81/${REQUEST}/${arqx} > /dev/null 2>&1 && {
  210. verificar_arq "${arqx}"
  211. } || {
  212. msg -verm2 "fallida!!!"
  213. sleep 2s
  214. error_fun
  215. }
  216. done
  217. msg -verd "completa!!!"
  218. sleep 2s
  219. rm $HOME/lista-arq
  220. [[ -d ${SCPinstal} ]] && rm -rf ${SCPinstal}
  221. rm -rf /usr/bin/menu
  222. rm -rf /usr/bin/adm
  223. rm -rf /usr/bin/ADMRufu
  224. echo "${ADMRufu}/menu" > /usr/bin/menu && chmod +x /usr/bin/menu
  225. echo "${ADMRufu}/menu" > /usr/bin/adm && chmod +x /usr/bin/adm
  226. echo "${ADMRufu}/menu" > /usr/bin/ADMRufu && chmod +x /usr/bin/ADMRufu
  227. sed -i '/Rufu/d' /root/bash.bashrc
  228. [[ -z $(echo $PATH|grep "/usr/games") ]] && echo 'if [[ $(echo $PATH|grep "/usr/games") = "" ]]; then PATH=$PATH:/usr/games; fi' >> /etc/bash.bashrc
  229. echo '[[ $UID = 0 ]] && screen -dmS up /etc/ADMRufu/chekup.sh' >> /etc/bash.bashrc
  230. echo 'v=$(cat /etc/ADMRufu/vercion)' >> /etc/bash.bashrc
  231. echo '[[ -e /etc/ADMRufu/new_vercion ]] && up=$(cat /etc/ADMRufu/new_vercion) || up=$v' >> /etc/bash.bashrc
  232. echo -e "[[ \$(date '+%s' -d \$up) -gt \$(date '+%s' -d \$(cat /etc/ADMRufu/vercion)) ]] && v2=\"Nueva Vercion disponible: \$v >>> \$up\" || v2=\"Script Vercion: \$v\"" >> /etc/bash.bashrc
  233. echo '[[ -e "/etc/ADMRufu/tmp/message.txt" ]] && mess1="$(less /etc/ADMRufu/tmp/message.txt)"' >> /etc/bash.bashrc
  234. echo '[[ -z "$mess1" ]] && mess1="@Rufu99"' >> /etc/bash.bashrc
  235. echo 'clear && echo -e "\n$(figlet -f big.flf " ADMRufu")\n RESELLER : $mess1 \n\n Para iniciar ADMRufu escriba: menu \n\n $v2\n\n"|lolcat' >> /etc/bash.bashrc
  236. update-locale LANG=en_US.UTF-8 LANGUAGE=en
  237. clear
  238. title "-- ADMRufu INSTALADO --"
  239. else
  240. [[ -e $HOME/lista-arq ]] && rm $HOME/lista-arq
  241. clear
  242. msg -bar
  243. print_center -verm2 "KEY INVALIDA"
  244. msg -bar
  245. print_center -ama "Esta key no es valida o ya fue usada"
  246. print_center -ama "Contacta con @Rufu99"
  247. msg -bar
  248. rm -rf ${module}
  249. exit
  250. fi
  251. mv -f ${module} /etc/ADMRufu/module
  252. time_reboot "10"