Add 'Scripts/EnableSSL.sh'
This commit is contained in:
26
Scripts/EnableSSL.sh
Normal file
26
Scripts/EnableSSL.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#Setting Vars
|
||||
domain=DomainName
|
||||
domainwww=DomainWWW
|
||||
email=Email
|
||||
webserver=WebServer
|
||||
webservice=WebServer
|
||||
if [ $webservice = apache ]; then
|
||||
webservice=apache2
|
||||
fi
|
||||
|
||||
#Backing-up and removing current config
|
||||
sed -n '/#beginConf/,/#endConf/p' /etc/"$webservice"/sites-enabled/"domain" > /tmp/"$domain"-config
|
||||
sed -n -i '/#beginConf/{:a;N;/#endConf/!ba;N;s/.*\n/#ConfHere1\n/};p' /etc/"$webservice"/sites-enabled/"domain"
|
||||
systemctl restart $webservice
|
||||
|
||||
#Enabling SSL
|
||||
if [ $domainwww = 1 ]; then
|
||||
certbot --"$webserv" -n -d "$domain" -d "www.$domain" -m "$email" --hsts --redirect --no-eff-email --agree-tos
|
||||
elif [ $domainwww = 0 ]; then
|
||||
certbot --"$webserv" -n -d "$domain" -m "$email" --hsts --redirect --no-eff-email --agree-tos
|
||||
fi
|
||||
|
||||
#Restoring config
|
||||
sed -i -e "0,/^#ConfHere/s/\(^#Conf.*\)/#ConfHere1 /" -e '/#ConfHere1/ r /tmp/"$domain"-config' -e '/#ConfHere/c\' /etc/"$webservice"/sites-enabled/"domain"
|
||||
|
||||
systemctl restart $webservice
|
||||
Reference in New Issue
Block a user