1
0

gestor.sh 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #!/bin/bash
  2. declare -A cor=( [0]="\033[1;37m" [1]="\033[1;34m" [2]="\033[1;31m" [3]="\033[1;33m" [4]="\033[1;32m" )
  3. SCPdir="/etc/newadm" && [[ ! -d ${SCPdir} ]] && exit 1
  4. SCPfrm="/etc/ger-frm" && [[ ! -d ${SCPfrm} ]] && exit
  5. SCPinst="/etc/ger-inst" && [[ ! -d ${SCPinst} ]] && exit
  6. SCPidioma="${SCPdir}/idioma" && [[ ! -e ${SCPidioma} ]] && touch ${SCPidioma}
  7. fun_bar () {
  8. comando="$1"
  9. _=$(
  10. $comando > /dev/null 2>&1
  11. ) & > /dev/null
  12. pid=$!
  13. while [[ -d /proc/$pid ]]; do
  14. echo -ne " \033[1;33m["
  15. for((i=0; i<10; i++)); do
  16. echo -ne "\033[1;31m##"
  17. sleep 0.2
  18. done
  19. echo -ne "\033[1;33m]"
  20. sleep 1s
  21. echo
  22. tput cuu1
  23. tput dl1
  24. done
  25. echo -e " \033[1;33m[\033[1;31m########################################\033[1;33m] - \033[1;32m100%\033[0m"
  26. sleep 1s
  27. }
  28. update_pak () {
  29. echo -ne " \033[1;31m[ ! ] apt-get update"
  30. apt-get update -y > /dev/null 2>&1 && echo -e "\033[1;32m [OK]" || echo -e "\033[1;31m [FAIL]"
  31. echo -ne " \033[1;31m[ ! ] apt-get upgrade"
  32. apt-get upgrade -y > /dev/null 2>&1 && echo -e "\033[1;32m [OK]" || echo -e "\033[1;31m [FAIL]"
  33. msg -bar
  34. return
  35. }
  36. reiniciar_ser () {
  37. echo -ne " \033[1;31m[ ! ] Services stunnel4 restart"
  38. service stunnel4 restart > /dev/null 2>&1
  39. [[ -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]"
  40. echo -ne " \033[1;31m[ ! ] Services squid restart"
  41. service squid restart > /dev/null 2>&1 && echo -e "\033[1;32m [OK]" || echo -e "\033[1;31m [FAIL]"
  42. echo -ne " \033[1;31m[ ! ] Services squid3 restart"
  43. service squid3 restart > /dev/null 2>&1 && echo -e "\033[1;32m [OK]" || echo -e "\033[1;31m [FAIL]"
  44. echo -ne " \033[1;31m[ ! ] Services apache2 restart"
  45. service apache2 restart > /dev/null 2>&1
  46. [[ -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]"
  47. echo -ne " \033[1;31m[ ! ] Services openvpn restart"
  48. service openvpn restart > /dev/null 2>&1
  49. [[ -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]"
  50. echo -ne " \033[1;31m[ ! ] Services dropbear restart"
  51. service dropbear restart > /dev/null 2>&1
  52. [[ -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]"
  53. echo -ne " \033[1;31m[ ! ] Services ssh restart"
  54. service ssh restart > /dev/null 2>&1
  55. [[ -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]"
  56. echo -ne " \033[1;31m[ ! ] Services fail2ban restart"
  57. (
  58. [[ -e /etc/init.d/ssh ]] && /etc/init.d/ssh restart
  59. fail2ban-client -x stop && fail2ban-client -x start
  60. ) > /dev/null 2>&1 && echo -e "\033[1;32m [OK]" || echo -e "\033[1;31m [FAIL]"
  61. msg -bar
  62. return
  63. }
  64. host_name () {
  65. unset name
  66. while [[ ${name} = "" ]]; do
  67. echo -ne "\033[1;37m $(fun_trans "Nuevo nombre del host"): " && read name
  68. tput cuu1 && tput dl1
  69. done
  70. hostnamectl set-hostname $name
  71. if [ $(hostnamectl status | head -1 | awk '{print $3}') = "${name}" ]; then
  72. echo -e "\033[1;33m $(fun_trans "Host alterado corretamente")!, $(fun_trans "reiniciar VPS")"
  73. else
  74. echo -e "\033[1;33m $(fun_trans "Host no modificado")!"
  75. fi
  76. msg -bar
  77. return
  78. }
  79. pamcrack () {
  80. echo -e "${cor[3]} $(fun_trans "Liberar passwd para VURTL")"
  81. msg -bar
  82. echo -ne " $(fun_trans "Desea Seguir?") [S/N]: "; read x
  83. [[ $x = @(n|N) ]] && msg -bar && return
  84. echo -e ""
  85. fun_bar "service ssh restart"
  86. sed -i 's/.*pam_cracklib.so.*/password sufficient pam_unix.so sha512 shadow nullok try_first_pass #use_authtok/' /etc/pam.d/common-password
  87. fun_bar "service ssh restart"
  88. echo -e ""
  89. echo -e " \033[1;31m[ ! ]\033[1;33m $(fun_trans "Configuraciones VURTL aplicadas")"
  90. msg -bar
  91. return
  92. }
  93. timemx () {
  94. rm -rf /etc/localtime
  95. ln -s /usr/share/zoneinfo/America/Merida /etc/localtime
  96. echo -e " FECHA LOCAL MX APLICADA!"
  97. }
  98. timearg () {
  99. rm -rf /etc/localtime
  100. ln -sf /usr/share/zoneinfo/America/Argentina/Buenos_Aires /etc/localtime
  101. echo -e " FECHA LOCAL ARG APLICADA!"
  102. }
  103. gestor_fun () {
  104. clear
  105. msg -bar
  106. echo -e " ${cor[3]} AJUSTES INTERNOS DEL VPS "
  107. msg -bar
  108. while true; do
  109. echo -e "${cor[4]} [1] > \033[1;36mACTULIZAR REPOSITORIOS APT"
  110. echo -e "${cor[4]} [2] > \033[1;36mREINICIAR SERVICIOS"
  111. echo -e "${cor[4]} [3] > \033[1;36mCAMBIAR HOSTNAME VPS"
  112. echo -e "${cor[4]} [4] > \033[1;36mCAMBIAR HORA LOCAL MX"
  113. echo -e "${cor[4]} [5] > \033[1;36mCAMBIAR HORA LOCAL AR"
  114. echo -e "${cor[4]} [0] > VOLVER"
  115. while [[ ${opx} != @(0|[1-9]) ]]; do
  116. msg -bar
  117. echo -ne " Seleccione una Opcion: \033[1;37m" && read opx
  118. tput cuu1 && tput dl1
  119. done
  120. case $opx in
  121. 0)
  122. return;;
  123. 1)
  124. update_pak
  125. break;;
  126. 2)
  127. reiniciar_ser
  128. break;;
  129. 3)
  130. host_name
  131. break;;
  132. 4)
  133. timemx
  134. break;;
  135. 5)
  136. timearg
  137. break;;
  138. esac
  139. done
  140. }
  141. gestor_fun