dimanche 27 décembre 2020

bash script with if condition [closed]

I want this in this script To make sure that the certificate is created for the domain either www or none www before it is created, and if he did not create it, he should try again -------------------

                /usr/local/bin/add-virtualhost create $1 $2
          sitesAvailabledomainSSL=/etc/apache2/sites-available/$2-le-ssl.conf
       if [ ! -e "$sitesAvailabledomainSSL" ]; then
      echo 1 | certbot -d "$1"
      else
        echo 1 | certbot --expand -d "$3"
        fi

           virtualHostStart='### start virtual host'
            virtualHostStart="${virtualHostStart} ${1}"
           virtualHostEnd='### end virtual host'
           virtualHostEnd="${virtualHostEnd} ${1}"

###   regular expression to remove wrong virtual host from the SSL file
sed -zE -i "s/<IfModule mod_ssl.c>(\r\n|\r|\n)<VirtualHost \*\:80>(\r\n|\r|\n)$virtualHostStart.* 
$virtualHostEnd(\r\n|\r|\n)<\/VirtualHost>(\r\n|\r|\n)<\/IfModule>//" /etc/apache2/sites- 
available/$2-le-ssl.conf

 ### restart Apache
 /etc/init.d/apache2 reload
------------------

any ideas?

Aucun commentaire:

Enregistrer un commentaire