Tidying
This commit is contained in:
parent
0a72fa029f
commit
0318ca8edf
|
@ -146,7 +146,9 @@ if [ ! -d /etc/ssl/mycerts ]; then
|
|||
mkdir /etc/ssl/mycerts
|
||||
fi
|
||||
|
||||
if [ $LETSENCRYPT_HOSTNAME ]; then
|
||||
CERTFILE=$HOSTNAME
|
||||
|
||||
function add_cert_letsencrypt {
|
||||
CERTFILE=$LETSENCRYPT_HOSTNAME
|
||||
|
||||
if [ ! -d $INSTALL_DIR ]; then
|
||||
|
@ -170,7 +172,6 @@ if [ $LETSENCRYPT_HOSTNAME ]; then
|
|||
systemctl stop nginx
|
||||
|
||||
cd ${INSTALL_DIR}/letsencrypt
|
||||
# TODO this requires user interaction - is there a non-interactive mode?
|
||||
./letsencrypt-auto certonly --server $LETSENCRYPT_SERVER --standalone -d $LETSENCRYPT_HOSTNAME
|
||||
if [ ! "$?" = "0" ]; then
|
||||
echo $"Failed to install letsencrypt for domain $LETSENCRYPT_HOSTNAME"
|
||||
|
@ -217,8 +218,9 @@ if [ $LETSENCRYPT_HOSTNAME ]; then
|
|||
echo $"Certificate for $LETSENCRYPT_HOSTNAME could not be pinned"
|
||||
exit 62878
|
||||
fi
|
||||
else
|
||||
CERTFILE=$HOSTNAME
|
||||
}
|
||||
|
||||
function add_cert_selfsigned {
|
||||
if [[ $ORGANISATION == "Freedombone-CA" ]]; then
|
||||
CERTFILE="ca-$HOSTNAME"
|
||||
fi
|
||||
|
@ -236,21 +238,39 @@ else
|
|||
echo $"Certificate for $CERTFILE could not be pinned"
|
||||
exit 62879
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# generate DH params
|
||||
if [ ! $NODH ]; then
|
||||
function generate_dh_params {
|
||||
if [ ! $NODH ]; then
|
||||
if [ ! -f /etc/ssl/certs/${CERTFILE}.dhparam ]; then
|
||||
${PROJECT_NAME}-dhparam -h ${CERTFILE} --fast yes
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -f /etc/init.d/nginx ]; then
|
||||
function restart_web_server {
|
||||
if [ -f /etc/init.d/nginx ]; then
|
||||
/etc/init.d/nginx reload
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Create a bundle of your certificates
|
||||
cat /etc/ssl/mycerts/*.crt /etc/ssl/mycerts/*.pem > /etc/ssl/${PROJECT_NAME}-bundle.crt
|
||||
tar -czvf /etc/ssl/${PROJECT_NAME}-certs.tar.gz /etc/ssl/mycerts/*.crt /etc/ssl/mycerts/*.pem
|
||||
function make_cert_bundle {
|
||||
# Create a bundle of your certificates
|
||||
cat /etc/ssl/mycerts/*.crt /etc/ssl/mycerts/*.pem > /etc/ssl/${PROJECT_NAME}-bundle.crt
|
||||
tar -czvf /etc/ssl/${PROJECT_NAME}-certs.tar.gz /etc/ssl/mycerts/*.crt /etc/ssl/mycerts/*.pem
|
||||
}
|
||||
|
||||
function create_cert {
|
||||
if [ $LETSENCRYPT_HOSTNAME ]; then
|
||||
add_cert_letsencrypt
|
||||
else
|
||||
add_cert_selfsigned
|
||||
fi
|
||||
}
|
||||
|
||||
create_cert
|
||||
generate_dh_params
|
||||
restart_web_server
|
||||
make_cert_bundle
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue