Initial draft
This commit is contained in:
parent
f71d76bc39
commit
433c7c3f94
|
@ -68,6 +68,11 @@ function send_notification
|
|||
echo -e "$2" | mail $opt -s "$1" ${EMAIL}
|
||||
}
|
||||
|
||||
function become
|
||||
{
|
||||
sudo su -
|
||||
}
|
||||
|
||||
function check_values
|
||||
{
|
||||
|
||||
|
|
|
@ -30,6 +30,11 @@ function get_cert
|
|||
/root/.acme.sh/acme.sh --issue --domain $_domain --webroot /srv/http-content-combined/ --cert-file /etc/nginx/ssl/${_domain}.crt --key-file /etc/nginx/ssl/${_domain}.key --fullchain-file /etc/nginx/ssl/${_domain}-fullchain.crt
|
||||
}
|
||||
|
||||
function reload_nginx
|
||||
{
|
||||
systemctl reload nginx
|
||||
}
|
||||
|
||||
_cwd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
_bootstrap=${_cwd}/bootstrap.sh
|
||||
|
||||
|
@ -112,9 +117,8 @@ if test -z "$_root" -a -z "$_backend"; then
|
|||
err "You must specify either --root or --backend!"
|
||||
fi
|
||||
|
||||
echo "Creating Nginx configuration..."
|
||||
_vhost_conf_file=/etc/nginx/conf.d/${_domain}.conf
|
||||
|
||||
# gain priviledges
|
||||
become
|
||||
|
||||
echo -n "Checking if /srv/http-content-combined/ exists?"
|
||||
if ! test -d /srv/http-content-combined; then
|
||||
|
@ -124,6 +128,17 @@ else
|
|||
echo " Yes!"
|
||||
fi
|
||||
|
||||
echo "Creating Nginx configuration..."
|
||||
_vhost_conf_file=/etc/nginx/conf.d/${_domain}.conf
|
||||
|
||||
echo -n "Checking if $_vhost_conf_file exists? "
|
||||
if test -f $_vhost_conf_file; then
|
||||
echo "Removing!"
|
||||
rm $_vhost_conf_file
|
||||
else
|
||||
echo "No!"
|
||||
fi
|
||||
|
||||
cat << EOF > $_vhost_conf_file
|
||||
#### Description
|
||||
## Type: HTTP
|
||||
|
@ -142,6 +157,18 @@ server {
|
|||
return 302 https://${_domain}\$request_uri;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
echo "Setting permissions on conf file..."
|
||||
setfacl -m user:sysadmin:rw $_vhost_conf_file
|
||||
|
||||
echo "Reloading Nginx..."
|
||||
reload_nginx
|
||||
|
||||
echo "Retrieving Let's Encrypt Certificate..."
|
||||
get_cert
|
||||
|
||||
cat << EOF >> $_vhost_conf_file
|
||||
|
||||
server {
|
||||
listen ${_listenip}443 http2 ssl;
|
||||
|
@ -160,8 +187,5 @@ ${_locationblock}
|
|||
}
|
||||
EOF
|
||||
|
||||
echo "Setting permissions on conf file..."
|
||||
#setfacl -m user:sysadmin:rw $_vhost_conf_file
|
||||
|
||||
echo "Retrieving Let's Encrypt Certificate..."
|
||||
get_cert
|
||||
echo "Reloading Nginx..."
|
||||
reload_nginx
|
||||
|
|
Loading…
Reference in New Issue