96 lines
1.7 KiB
Bash
Executable File
96 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
|
|
gen_nginx_acme_conf(){
|
|
domain=$1
|
|
alt_domain=$2
|
|
nginx_run=`rcctl check nginx`
|
|
|
|
if [ "$nginx_run" == "nginx(ok)" ]; then
|
|
cat > test/$domain <<EOF
|
|
server {
|
|
listen 80;
|
|
server_name $alt_domain $domain;
|
|
|
|
include snippets/acme-challenge.conf;
|
|
|
|
root /htdocs;
|
|
|
|
}
|
|
EOF
|
|
|
|
# rcctl restart nginx
|
|
else
|
|
echo "Service NGINX not runnig"
|
|
exit 1
|
|
fi
|
|
|
|
}
|
|
|
|
gen_acme_client_conf(){
|
|
domain=$1
|
|
alt_domain=$2
|
|
if [ "$alt_domain" == "" ]; then
|
|
cat >> my_configuration/ssl/$domain-acme-client.conf <<EOF
|
|
|
|
domain $domain {
|
|
domain key "/etc/ssl/private/$domain.key"
|
|
domain full chain certificate "/etc/ssl/$domain.crt"
|
|
sign with letsencrypt
|
|
}
|
|
|
|
EOF
|
|
else
|
|
cat >> my_configuration/ssl/$domain-acme-client.conf <<EOF
|
|
|
|
domain $domain {
|
|
alternative names { $alt_domain }
|
|
domain key "/etc/ssl/private/$domain.key"
|
|
domain full chain certificate "/etc/ssl/$domain.crt"
|
|
sign with letsencrypt
|
|
}
|
|
|
|
EOF
|
|
fi
|
|
|
|
}
|
|
|
|
install_utils(){
|
|
cp -v utils/renew_https_certificate /usr/local/bin/renew_https_certificate
|
|
chmod u+x /usr/local/bin/renew_https_certificate
|
|
}
|
|
|
|
get_certificate(){
|
|
domain=$1
|
|
|
|
/usr/local/bin/renew_https_certificate $domain
|
|
}
|
|
|
|
usage(){
|
|
print "This program ask 3 arguments : \n"
|
|
print "First is email with domain name the second is list of alternatives domains with \" \" \n"
|
|
print "the last arguments is for share the ssl cert with xmpp daemon add xmpp at the end or not"
|
|
print "\t $0 domain.tld \"a.domain.tld b.domain.tld c.domain.tld\""
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -z $1 ];
|
|
then
|
|
usage
|
|
exit 3;
|
|
fi
|
|
|
|
if [ -e /etc/acme-client.conf ]; then
|
|
echo ok
|
|
else
|
|
echo nok
|
|
fi
|
|
|
|
|
|
domain=$1
|
|
alt_domain=$2
|
|
|
|
gen_nginx_acme_conf $domain
|