Created
April 21, 2025 15:06
-
-
Save dalthonmh/dac7298e5e3e74a512025d70f4bd538e to your computer and use it in GitHub Desktop.
Script de instalación de https con certbot en servidor Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Name: install_https.sh | |
# Purpose: Instalar https con certbot en servidor ubuntu | |
# Author: dalthonmh - 21 abril 2025 | |
#PARAMETROS | |
DOMINIO=${1:-'dominio'} | |
CORREO=${2:-'correo'} | |
#DOMINIO | |
if [ "$DOMINIO" = "dominio" ]; then | |
echo "No ha ingresado el dominio, ejecute el dominio así: ./install_https.sh dominio.com" | |
exit 1 | |
fi | |
if [ "$CORREO" = "correo" ]; then | |
echo "No ha ingresado el correo. Ejecute el script así: ./install_https.sh dominio.com [email protected]" | |
exit 1 | |
fi | |
#VERIFICA INSTALACIÓN | |
if ! command -v nginx &> /dev/null; then | |
echo "Nginx no está instalado. Instálalo con: sudo apt install nginx" | |
exit 1 | |
fi | |
# ACTUALIZAR E INSTALAR CERTBOT | |
sudo apt update | |
sudo apt install -y snapd | |
sudo snap install core; sudo snap refresh core | |
sudo apt-get remove certbot | |
sudo snap install --classic certbot | |
sudo ln -s /snap/bin/certbot /usr/bin/certbot | |
# EJECUTAR CERTBOT SIN INTERACCIÓN | |
if sudo certbot --nginx -d "$DOMINIO" -d "www.$DOMINIO" \ | |
--email "$CORREO" \ | |
--agree-tos \ | |
--no-eff-email \ | |
--non-interactive; then | |
echo "Certificado SSL instalado correctamente para $DOMINIO" | |
else | |
echo "Falló la instalación del certificado SSL" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment