byprez

vpsmanagersetup.sh

Mar 3rd, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 8.70 KB | None | 0 0
  1. #!/bin/bash
  2. tput setaf 7 ; tput setab 4 ; tput bold ; printf '%35s%s%-20s\n' "VPS Manager 2.0.1 Create by Phreaker56 and traslated by Greyvin" ; tput sgr0
  3. tput setaf 3 ; tput bold ; echo "" ; echo "Este script ara:" ; echo ""
  4. echo "● Instalar y configurar el proxy squid en los puertos 80, 3128, 8080 y 8799" ; echo "  para permitir conexiones SSH para este servidor"
  5. echo "● Configurar OpenSSH para ejecutarse en los puertos 22 y 443"
  6. echo "● Instalar un conjunto de secuencias de comandos y comandos del sistema para la gestión de los usuarios" ; tput sgr0
  7. echo ""
  8. tput setaf 3 ; tput bold ; read -n 1 -s -p "Pulse cualquier tecla para continuar..." ; echo "" ; echo "" ; tput sgr0
  9. tput setaf 2 ; tput bold ; echo "   Termos de Uso" ; tput sgr0
  10. echo ""
  11. echo "Condiciones de uso de 'VPS Manager 2.0' :"
  12. echo ""
  13. echo "1. Tu puedes:"
  14. echo "a. Instalar y utilizar 'VPS Manager 2.0' en su servidor(es)."
  15. echo "b. Criar, gerenciar e remover um número ilimitado de usuários através desse conjunto de scripts."
  16. echo "c. Todos los creditos a Phreaker56."
  17. echo "c. Solamente traduje a español el VPS Manager, si hay algun problema probablemente haya sido durante la traduccion."
  18. echo ""
  19. tput setaf 3 ; tput bold ; read -n 1 -s -p "Aperte qualquer tecla para continuar..." ; echo "" ; echo "" ; tput sgr0
  20. IP=$(wget -qO- ipv4.icanhazip.com)
  21. read -p "Para continuar confirme o IP de este servidor: " -e -i $IP ipdovps
  22. if [ -z "$ipdovps" ]
  23. then
  24.     tput setaf 7 ; tput setab 1 ; tput bold ; echo "" ; echo "" ; echo " No ha introducido la dirección IP de este servidor. Inténtalo de nuevo. " ; echo "" ; echo "" ; tput sgr0
  25.     exit 1
  26. fi
  27. if [ -f "/root/usuarios.db" ]
  28. then
  29. tput setaf 6 ; tput bold ;  echo ""
  30.     echo "Se encontró una base de datos de usuario ('usuarios.db')!"
  31.     echo "¿Quieres mantenerlo (preservando el límite de conexiones simultáneas de los usuarios)"
  32.     echo "o crear una nueva base de datos?"
  33.     tput setaf 6 ; tput bold ;  echo ""
  34.     echo "[1] Manter Base de Datos Atual"
  35.     echo "[2] Crear una nueva base de datos"
  36.     echo "" ; tput sgr0
  37.     read -p "Opcion?: " -e -i 1 optiondb
  38. else
  39.     awk -F : '$3 >= 500 { print $1 " 1" }' /etc/passwd | grep -v '^nobody' > /root/usuarios.db
  40. fi
  41. echo ""
  42. read -p "Quieres activar la compresión de SSH (puede aumentar el consumo de memoria RAM)? [s/n]) " -e -i n sshcompression
  43. echo ""
  44. tput setaf 7 ; tput setab 4 ; tput bold ; echo "" ; echo "Espere, configuracion automática" ; echo "" ; tput sgr0
  45. sleep 3
  46. apt-get update -y
  47. apt-get upgrade -y
  48. rm /bin/criarusuario /bin/expcleaner /bin/sshlimiter /bin/addhost /bin/listar /bin/sshmonitor /bin/ayuda > /dev/null
  49. rm /root/ExpCleaner.sh /root/CriarUsuario.sh /root/sshlimiter.sh > /dev/null
  50. apt-get install squid3 bc screen nano unzip dos2unix wget -y
  51. killall apache2
  52. apt-get purge apache2 -y
  53. if [ -f "/usr/sbin/ufw" ] ; then
  54.     ufw allow 443/tcp ; ufw allow 80/tcp ; ufw allow 3128/tcp ; ufw allow 8799/tcp ; ufw allow 8080/tcp
  55. fi
  56. if [ -d "/etc/squid3/" ]
  57. then
  58.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLdDJpemlxZ0lvMEk -O /tmp/sqd1
  59.     echo "acl url3 dstdomain -i $ipdovps" > /tmp/sqd2
  60.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLUFczV2FWWnktcWM -O /tmp/sqd3
  61.     cat /tmp/sqd1 /tmp/sqd2 /tmp/sqd3 > /etc/squid3/squid.conf
  62.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLVDhhRjZiNENLRk0
  63.     echo " " >> /etc/squid3/payload.txt
  64.     grep -v "^Port 443" /etc/ssh/sshd_config > /tmp/ssh && mv /tmp/ssh /etc/ssh/sshd_config
  65.     echo "Port 443" >> /etc/ssh/sshd_config
  66.     grep -v "^PasswordAuthentication yes" /etc/ssh/sshd_config > /tmp/passlogin && mv /tmp/passlogin /etc/ssh/sshd_config
  67.     echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
  68.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLM25jcVZvLWczME0 -O /bin/addhost
  69.     chmod +x /bin/addhost
  70.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLc3JwMWI1YmpsQVU -O /bin/alterarsenha
  71.     chmod +x /bin/alterarsenha
  72.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLb3ZmVXlqWGRCVVU -O /bin/criarusuario
  73.     chmod +x /bin/criarusuario
  74.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLTGl1VUF0R1hXN0E -O /bin/delhost
  75.     chmod +x /bin/delhost
  76.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLWGNuMl8zYTc4MEk -O /bin/expcleaner
  77.     chmod +x /bin/expcleaner
  78.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLWHlac0R2RzY4Snc -O /bin/mudardata
  79.     chmod +x /bin/mudardata
  80.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLSnNuTGV3UjNIN2s -O /bin/remover
  81.     chmod +x /bin/remover
  82.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLVUlCRDlWa29NU00 -O /bin/sshlimiter
  83.     chmod +x /bin/sshlimiter
  84.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLTW5peUdsZ1VkNU0 -O /bin/alterarlimite
  85.     chmod +x /bin/alterarlimite
  86.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLWUtQWkE1UWJqVnc -O /bin/ayuda
  87.     chmod +x /bin/ajuda
  88.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLakNLM3ItRjB2MGM -O /bin/sshmonitor
  89.     chmod +x /bin/sshmonitor
  90.     if [ ! -f "/etc/init.d/squid3" ]
  91.     then
  92.         service squid3 reload > /dev/null
  93.     else
  94.         /etc/init.d/squid3 reload > /dev/null
  95.     fi
  96.     if [ ! -f "/etc/init.d/ssh" ]
  97.     then
  98.         service ssh reload > /dev/null
  99.     else
  100.         /etc/init.d/ssh reload > /dev/null
  101.     fi
  102. fi
  103. if [ -d "/etc/squid/" ]
  104. then
  105.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLdDJpemlxZ0lvMEk -O /tmp/sqd1
  106.     echo "acl url3 dstdomain -i $ipdovps" > /tmp/sqd2
  107.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLVDFSSWNCazF2MXc -O /tmp/sqd3
  108.     cat /tmp/sqd1 /tmp/sqd2 /tmp/sqd3 > /etc/squid/squid.conf
  109.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLVDhhRjZiNENLRk0 -O /etc/squid/payload.txt
  110.     echo " " >> /etc/squid/payload.txt
  111.     grep -v "^Port 443" /etc/ssh/sshd_config > /tmp/ssh && mv /tmp/ssh /etc/ssh/sshd_config
  112.     echo "Port 443" >> /etc/ssh/sshd_config
  113.     grep -v "^PasswordAuthentication yes" /etc/ssh/sshd_config > /tmp/passlogin && mv /tmp/passlogin /etc/ssh/sshd_config
  114.     echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
  115.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLUUhIQ3RoRElXZzQ -O /bin/addhost
  116.     chmod +x /bin/addhost
  117.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLc3JwMWI1YmpsQVU -O /bin/alterarsenha
  118.     chmod +x /bin/alterarsenha
  119.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLb3ZmVXlqWGRCVVU -O /bin/criarusuario
  120.     chmod +x /bin/criarusuario
  121.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLZnlEdXdUUXZteG8 -O /bin/delhost
  122.     chmod +x /bin/delhost
  123.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLWGNuMl8zYTc4MEk -O /bin/expcleaner
  124.     chmod +x /bin/expcleaner
  125.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLWHlac0R2RzY4Snc -O /bin/mudardata
  126.     chmod +x /bin/mudardata
  127.     wget hhttps://docs.google.com/uc?export=download&id=0B0aERTnPt_tLSnNuTGV3UjNIN2s -O /bin/remover
  128.     chmod +x /bin/remover
  129.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLVUlCRDlWa29NU00 -O /bin/sshlimiter
  130.     chmod +x /bin/sshlimiter
  131.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLTW5peUdsZ1VkNU0 -O /bin/alterarlimite
  132.     chmod +x /bin/alterarlimite
  133.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLWUtQWkE1UWJqVnc -O /bin/ayuda
  134.     chmod +x /bin/ajuda
  135.     wget https://docs.google.com/uc?export=download&id=0B0aERTnPt_tLakNLM3ItRjB2MGM -O /bin/sshmonitor
  136.     chmod +x /bin/sshmonitor
  137.     if [ ! -f "/etc/init.d/squid" ]
  138.     then
  139.         service squid reload > /dev/null
  140.     else
  141.         /etc/init.d/squid reload > /dev/null
  142.     fi
  143.     if [ ! -f "/etc/init.d/ssh" ]
  144.     then
  145.         service ssh reload > /dev/null
  146.     else
  147.         /etc/init.d/ssh reload > /dev/null
  148.     fi
  149. fi
  150. echo ""
  151. tput setaf 7 ; tput setab 4 ; tput bold ; echo "Proxy squid instalado y en ejecución en los puertos: 80, 3128, 8080 y 8799" ; tput sgr0
  152. tput setaf 7 ; tput setab 4 ; tput bold ; echo "OpenSSH se ejecuta en los puertos 22 y 443" ; tput sgr0
  153. tput setaf 7 ; tput setab 4 ; tput bold ; echo "Scripts para la gestión de usuarios instalados" ; tput sgr0
  154. tput setaf 7 ; tput setab 4 ; tput bold ; echo "Lea la documentación para evitar preguntas y problemas!" ; tput sgr0
  155. tput setaf 7 ; tput setab 4 ; tput bold ; echo "Para ver los comandos disponibles, usar el comando: ayuda" ; tput sgr0
  156. echo ""
  157. if [[ "$optiondb" = '2' ]]; then
  158.     awk -F : '$3 >= 500 { print $1 " 1" }' /etc/passwd | grep -v '^nobody' > /root/usuarios.db
  159. fi
  160. if [[ "$sshcompression" = 's' ]]; then
  161.     grep -v "^Compression yes" /etc/ssh/sshd_config > /tmp/sshcp && mv /tmp/sshcp /etc/ssh/sshd_config
  162.     echo "Compression yes" >> /etc/ssh/sshd_config
  163. fi
  164. if [[ "$sshcompression" = 'n' ]]; then
  165.     grep -v "^Compression yes" /etc/ssh/sshd_config > /tmp/sshcp && mv /tmp/sshcp /etc/ssh/sshd_config
  166. fi
  167. exit 1
Advertisement
Add Comment
Please, Sign In to add comment