gestor.sh 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. # !/bin/bash
  2. # 27/01/2021
  3. clear
  4. clear
  5. declare -A cor=( [0]="\033[1;37m" [1]="\033[1;34m" [2]="\033[1;31m" [3]="\033[1;33m" [4]="\033[1;32m" )
  6. SCPdir="/etc/VPS-MX" && [[ ! -d ${SCPdir} ]] && exit 1
  7. SCPusr="${SCPdir}/controlador" && [[ ! -d ${SCPusr} ]] && mkdir ${SCPusr}
  8. SCPfrm="${SCPdir}/herramientas" && [[ ! -d ${SCPfrm} ]] && mkdir ${SCPfrm}
  9. SCPinst="${SCPdir}/protocolos" && [[ ! -d ${SCPfrm} ]] && mkdir ${SCPfrm}
  10. fun_bar () {
  11. comando="$1"
  12. _=$(
  13. $comando > /dev/null 2>&1
  14. ) & > /dev/null
  15. pid=$!
  16. while [[ -d /proc/$pid ]]; do
  17. echo -ne " \033[1;33m["
  18. for((i=0; i<10; i++)); do
  19. echo -ne "\033[1;31m##"
  20. sleep 0.2
  21. done
  22. echo -ne "\033[1;33m]"
  23. sleep 1s
  24. echo
  25. tput cuu1
  26. tput dl1
  27. done
  28. echo -e " \033[1;33m[\033[1;31m########################################\033[1;33m] - \033[1;32m100%\033[0m"
  29. sleep 1s
  30. }
  31. update_pak () {
  32. echo -ne " \033[1;31m[ ! ] apt-get update"
  33. apt-get update -y > /dev/null 2>&1 && echo -e "\033[1;32m [OK]" || echo -e "\033[1;31m [FAIL]"
  34. echo -ne " \033[1;31m[ ! ] apt-get upgrade"
  35. apt-get upgrade -y > /dev/null 2>&1 && echo -e "\033[1;32m [OK]" || echo -e "\033[1;31m [FAIL]"
  36. msg -bar
  37. return
  38. }
  39. reiniciar_ser () {
  40. echo -ne " \033[1;31m[ ! ] Services stunnel4 restart"
  41. service stunnel4 restart > /dev/null 2>&1
  42. [[ -e /etc/init.d/stunnel4 ]] && /etc/init.d/stunnel4 restart > /dev/null 2>&1 && echo -e "\033[1;32m [OK]" || echo -e "\033[1;31m [FAIL]"
  43. echo -ne " \033[1;31m[ ! ] Services squid restart"
  44. service squid restart > /dev/null 2>&1 && echo -e "\033[1;32m [OK]" || echo -e "\033[1;31m [FAIL]"
  45. echo -ne " \033[1;31m[ ! ] Services squid3 restart"
  46. service squid3 restart > /dev/null 2>&1 && echo -e "\033[1;32m [OK]" || echo -e "\033[1;31m [FAIL]"
  47. echo -ne " \033[1;31m[ ! ] Services apache2 restart"
  48. service apache2 restart > /dev/null 2>&1
  49. [[ -e /etc/init.d/apache2 ]] && /etc/init.d/apache2 restart > /dev/null 2>&1 && echo -e "\033[1;32m [OK]" || echo -e "\033[1;31m [FAIL]"
  50. echo -ne " \033[1;31m[ ! ] Services openvpn restart"
  51. service openvpn restart > /dev/null 2>&1
  52. [[ -e /etc/init.d/openvpn ]] && /etc/init.d/openvpn restart > /dev/null 2>&1 && echo -e "\033[1;32m [OK]" || echo -e "\033[1;31m [FAIL]"
  53. echo -ne " \033[1;31m[ ! ] Services dropbear restart"
  54. service dropbear restart > /dev/null 2>&1
  55. [[ -e /etc/init.d/dropbear ]] && /etc/init.d/dropbear restart > /dev/null 2>&1 && echo -e "\033[1;32m [OK]" || echo -e "\033[1;31m [FAIL]"
  56. echo -ne " \033[1;31m[ ! ] Services ssh restart"
  57. service ssh restart > /dev/null 2>&1
  58. [[ -e /etc/init.d/ssh ]] && /etc/init.d/ssh restart > /dev/null 2>&1 && echo -e "\033[1;32m [OK]" || echo -e "\033[1;31m [FAIL]"
  59. echo -ne " \033[1;31m[ ! ] Services fail2ban restart"
  60. (
  61. [[ -e /etc/init.d/ssh ]] && /etc/init.d/ssh restart
  62. fail2ban-client -x stop && fail2ban-client -x start
  63. ) > /dev/null 2>&1 && echo -e "\033[1;32m [OK]" || echo -e "\033[1;31m [FAIL]"
  64. msg -bar
  65. return
  66. }
  67. reiniciar_vps () {
  68. echo -ne " \033[1;31m[ ! ] Sudo Reboot"
  69. sleep 3s
  70. echo -e "\033[1;32m [OK]"
  71. (
  72. sudo reboot
  73. ) > /dev/null 2>&1
  74. msg -bar
  75. return
  76. }
  77. host_name () {
  78. unset name
  79. while [[ ${name} = "" ]]; do
  80. echo -ne "\033[1;37m $(fun_trans "Nuevo nombre del host"): " && read name
  81. tput cuu1 && tput dl1
  82. done
  83. hostnamectl set-hostname $name
  84. if [ $(hostnamectl status | head -1 | awk '{print $3}') = "${name}" ]; then
  85. echo -e "\033[1;33m $(fun_trans "Host alterado corretamente")!, $(fun_trans "reiniciar VPS")"
  86. else
  87. echo -e "\033[1;33m $(fun_trans "Host no modificado")!"
  88. fi
  89. msg -bar
  90. return
  91. }
  92. cambiopass () {
  93. echo -e "${cor[3]} $(fun_trans "Esta herramienta cambia la contraseña de su servidor vps")"
  94. echo -e "${cor[3]} $(fun_trans "Esta contraseña es utilizada como usuario") root"
  95. msg -bar
  96. echo -ne " $(fun_trans "Desea Seguir?") [S/N]: "; read x
  97. [[ $x = @(n|N) ]] && msg -bar && return
  98. msg -bar
  99. #Inicia Procedimentos
  100. echo -e "${cor[0]} $(fun_trans "Escriba su nueva contraseña")"
  101. msg -bar
  102. read -p " Nuevo passwd: " pass
  103. (echo $pass; echo $pass)|passwd 2>/dev/null
  104. sleep 1s
  105. msg -bar
  106. echo -e "${cor[3]} $(fun_trans "Contraseña cambiada con exito!")"
  107. echo -e "${cor[2]} $(fun_trans "Su contraseña ahora es"): ${cor[4]}$pass"
  108. msg -bar
  109. return
  110. }
  111. rootpass () {
  112. clear
  113. msg -bar
  114. echo -e "${cor[3]} Esta herramienta cambia a usuario root las VPS de "
  115. echo -e "${cor[3]} GoogleCloud y Amazon"
  116. msg -bar
  117. echo -ne " Desea Seguir? [S/N]: "; read x
  118. [[ $x = @(n|N) ]] && msg -bar && return
  119. msg -bar
  120. #Inicia Procedimentos
  121. echo -e " Aplicando Configuraciones"
  122. fun_bar "service ssh restart"
  123. #Parametros Aplicados
  124. sed -i "s;PermitRootLogin prohibit-password;PermitRootLogin yes;g" /etc/ssh/sshd_config
  125. sed -i "s;PermitRootLogin without-password;PermitRootLogin yes;g" /etc/ssh/sshd_config
  126. sed -i "s;PasswordAuthentication no;PasswordAuthentication yes;g" /etc/ssh/sshd_config
  127. msg -bar
  128. echo -e "Escriba su contraseña root actual o cambiela"
  129. msg -bar
  130. read -p " Nuevo passwd: " pass
  131. (echo $pass; echo $pass)|passwd 2>/dev/null
  132. sleep 1s
  133. msg -bar
  134. echo -e "${cor[3]} Configuraciones aplicadas con exito!"
  135. echo -e "${cor[2]} Su contraseña ahora es: ${cor[4]}$pass"
  136. service ssh restart > /dev/null 2>&1
  137. msg -bar
  138. return
  139. }
  140. pamcrack () {
  141. echo -e "${cor[3]} $(fun_trans "Liberar passwd para VURTL")"
  142. msg -bar
  143. echo -ne " $(fun_trans "Desea Seguir?") [S/N]: "; read x
  144. [[ $x = @(n|N) ]] && msg -bar && return
  145. echo -e ""
  146. fun_bar "service ssh restart"
  147. sed -i 's/.*pam_cracklib.so.*/password sufficient pam_unix.so sha512 shadow nullok try_first_pass #use_authtok/' /etc/pam.d/common-password
  148. fun_bar "service ssh restart"
  149. echo -e ""
  150. echo -e " \033[1;31m[ ! ]\033[1;33m $(fun_trans "Configuraciones VURTL aplicadas")"
  151. msg -bar
  152. return
  153. }
  154. timemx () {
  155. rm -rf /etc/localtime
  156. ln -s /usr/share/zoneinfo/America/Merida /etc/localtime
  157. echo -e " FECHA LOCAL MX APLICADA!"
  158. }
  159. timearg () {
  160. rm -rf /etc/localtime
  161. ln -sf /usr/share/zoneinfo/America/Argentina/Buenos_Aires /etc/localtime
  162. echo -e " FECHA LOCAL ARG APLICADA!"
  163. }
  164. gestor_fun () {
  165. clear
  166. msg -bar
  167. msg -tit
  168. echo -e " ${cor[3]} AJUSTES INTERNOS DEL VPS "
  169. msg -bar
  170. while true; do
  171. echo -e "${cor[4]} [1] > \033[1;36mACTULIZAR VPS"
  172. echo -e "${cor[4]} [2] > \033[1;36mREINICIAR SERVICIOS"
  173. echo -e "${cor[4]} [3] > \033[1;36mREINICIAR VPS"
  174. echo -e "${cor[4]} [4] > \033[1;36mCAMBIAR HOSTNAME VPS"
  175. echo -e "${cor[4]} [5] > \033[1;36mCAMBIAR CONTRASEÑA ROOT"
  176. echo -e "${cor[4]} [6] > \033[1;36mCAMBIAR HORA LOCAL MX"
  177. echo -e "${cor[4]} [7] > \033[1;36mCAMBIAR HORA LOCAL ARG"
  178. echo -e "${cor[2]} [8] > \033[1;100mAGREGAR ROOT a GoogleCloud y Amazon \033[0;37m"
  179. echo -e "$(msg -bar)\n${cor[4]} [0] > \e[97m\033[1;41m VOLVER \033[1;37m"
  180. while [[ ${opx} != @(0|[1-9]) ]]; do
  181. msg -bar
  182. echo -ne " Seleccione una Opcion: \033[1;37m" && read opx
  183. tput cuu1 && tput dl1
  184. done
  185. case $opx in
  186. 0)
  187. return;;
  188. 1)
  189. update_pak
  190. break;;
  191. 2)
  192. reiniciar_ser
  193. break;;
  194. 3)
  195. reiniciar_vps
  196. break;;
  197. 4)
  198. host_name
  199. break;;
  200. 5)
  201. cambiopass
  202. break;;
  203. 6)
  204. timemx
  205. break;;
  206. 7)
  207. timearg
  208. break;;
  209. 8)
  210. rootpass
  211. break;;
  212. esac
  213. done
  214. }
  215. gestor_fun