|
|
|
@@ -22,25 +22,35 @@ Install the reverse proxy called nginx with a predefined configuration and with
|
|
|
|
%make_install
|
|
|
|
%make_install
|
|
|
|
|
|
|
|
|
|
|
|
%post
|
|
|
|
%post
|
|
|
|
# Replace secrets in ovh.ini
|
|
|
|
if [ -z $SKIP_CERTBOT ]; then
|
|
|
|
envsubst < %{_sysconfdir}/certbot/ovh.ini > %{_sysconfdir}/certbot/.ovh.ini.new
|
|
|
|
# Check required OVH variables
|
|
|
|
if cmp --silent %{_sysconfdir}/certbot/.ovh.ini.new %{_sysconfdir}/certbot/ovh.ini; then
|
|
|
|
if [ -z $OVH_ENDPOINT ]; then echo "Missing env var OVH_ENDPOINT!" 1>&2; exit 1; fi
|
|
|
|
rm %{_sysconfdir}/certbot/.ovh.ini.new
|
|
|
|
if [ -z $OVH_APPLICATION_NAME ]; then echo "Missing env var OVH_APPLICATION_KEY!" 1>&2; exit 1; fi
|
|
|
|
else
|
|
|
|
if [ -z $OVH_APPLICATION_DESCRIPTION ]; then echo "Missing env var OVH_APPLICATION_DESCRIPTION!" 1>&2; exit 1; fi
|
|
|
|
|
|
|
|
if [ -z $OVH_APPLICATION_KEY ]; then echo "Missing env var OVH_APPLICATION_KEY!" 1>&2; exit 1; fi
|
|
|
|
|
|
|
|
if [ -z $OVH_APPLICATION_SECRET ]; then echo "Missing env var OVH_APPLICATION_SECRET!" 1>&2; exit 1; fi
|
|
|
|
|
|
|
|
if [ -z $OVH_CONSUMER_KEY ]; then echo "Missing env var OVH_CONSUMER_KEY!" 1>&2; exit 1; fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Replace secrets in ovh.ini
|
|
|
|
|
|
|
|
envsubst < %{_sysconfdir}/certbot/ovh.ini > %{_sysconfdir}/certbot/.ovh.ini.new
|
|
|
|
mv %{_sysconfdir}/certbot/.ovh.ini.new %{_sysconfdir}/certbot/ovh.ini
|
|
|
|
mv %{_sysconfdir}/certbot/.ovh.ini.new %{_sysconfdir}/certbot/ovh.ini
|
|
|
|
chmod 600 %{_sysconfdir}/certbot/ovh.ini
|
|
|
|
chmod 600 %{_sysconfdir}/certbot/ovh.ini
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Create virtualenv with certot
|
|
|
|
# Create virtualenv with certot
|
|
|
|
if [ ! -d "/opt/certbot" ]; then
|
|
|
|
if [ ! -d "/opt/certbot" ]; then
|
|
|
|
python3 -m venv /opt/certbot
|
|
|
|
python3 -m venv /opt/certbot
|
|
|
|
/opt/certbot/bin/pip install --upgrade pip certbot certbot-nginx certbot-dns-ovh
|
|
|
|
/opt/certbot/bin/pip install --upgrade pip certbot certbot-nginx certbot-dns-ovh
|
|
|
|
ln --symbolic --force --target-directory %{_sbindir} /opt/certbot/bin/certbot
|
|
|
|
ln --symbolic --force --target-directory %{_sbindir} /opt/certbot/bin/certbot
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Create certbot certificates
|
|
|
|
# Create certbot certificates
|
|
|
|
if ! certbot certificates --cert-name netoik.io | grep --quiet netoik.io; then
|
|
|
|
if ! certbot certificates --cert-name netoik.io | grep --quiet netoik.io; then
|
|
|
|
certbot certonly --cert-name netoik.io --non-interactive --agree-tos --email samuel.campos@netoik.io --dns-ovh --dns-ovh-credentials %{_sysconfdir}/certbot/ovh.ini -d *.netoik.io -d *.samuel-campos.fr
|
|
|
|
certbot certonly --cert-name netoik.io --non-interactive --agree-tos --email samuel.campos@netoik.io --dns-ovh --dns-ovh-credentials %{_sysconfdir}/certbot/ovh.ini -d *.netoik.io -d *.samuel-campos.fr
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
# Skipping certbot, so create self-signed certificate
|
|
|
|
|
|
|
|
mkdir --parents /etc/letsencrypt/live/netoik.io
|
|
|
|
|
|
|
|
openssl req -newkey rsa:4096 -nodes -keyout /etc/letsencrypt/live/netoik.io/privkey.pem -x509 -days 365 -out /etc/letsencrypt/live/netoik.io/fullchain.pem -subj "/C=US/ST=State/L=City/O=Organization/OU=Department/CN=netoik.io"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Create ssl dh params if not already exists
|
|
|
|
# Create ssl dh params if not already exists
|
|
|
|
|