From d7d87e01622aa1c50039575bc15dbaf1ea7c18ad Mon Sep 17 00:00:00 2001 From: samuel Date: Sat, 4 Apr 2026 06:38:58 +0200 Subject: [PATCH] feat: add skip certbot option --- README.md | 5 +++++ netoik-rp.spec | 43 ++++++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 4b71dd5..b2b6ee3 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,11 @@ Some commands to deploy the RPM package on server set +a ``` +- Install or upgrade without certbot (for testing environment) + ```shell + SKIP_CERTBOT=true dnf --nogpgcheck --refresh --assumeyes --best install netoik-rp + ``` + # Security Notes diff --git a/netoik-rp.spec b/netoik-rp.spec index 12027a4..f147bd6 100644 --- a/netoik-rp.spec +++ b/netoik-rp.spec @@ -22,30 +22,35 @@ Install the reverse proxy called nginx with a predefined configuration and with %make_install %post -# Replace secrets in ovh.ini -envsubst < %{_sysconfdir}/certbot/ovh.ini > %{_sysconfdir}/certbot/.ovh.ini.new -if cmp --silent %{_sysconfdir}/certbot/.ovh.ini.new %{_sysconfdir}/certbot/ovh.ini; then - rm %{_sysconfdir}/certbot/.ovh.ini.new -else +if [ -z $SKIP_CERTBOT ]; then + if [ -z $OVH_ENDPOINT ]; then echo "Missing env var OVH_ENDPOINT!" 1>&2; exit 1; fi + if [ -z $OVH_APPLICATION_NAME ]; then echo "Missing env var OVH_APPLICATION_KEY!" 1>&2; exit 1; fi + 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 chmod 600 %{_sysconfdir}/certbot/ovh.ini -fi -# Create virtualenv with certot -if [ ! -d "/opt/certbot" ]; then - python3 -m venv /opt/certbot - /opt/certbot/bin/pip install --upgrade pip certbot certbot-nginx certbot-dns-ovh - ln --symbolic --force --target-directory %{_sbindir} /opt/certbot/bin/certbot -fi + # Create virtualenv with certot + if [ ! -d "/opt/certbot" ]; then + python3 -m venv /opt/certbot + /opt/certbot/bin/pip install --upgrade pip certbot certbot-nginx certbot-dns-ovh + ln --symbolic --force --target-directory %{_sbindir} /opt/certbot/bin/certbot + fi -# Create certbot certificates -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 -fi + # Create certbot certificates + 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 + fi -# Create ssl dh params if not already exists -if [ ! -f "%{_sysconfdir}/letsencrypt/ssl-dhparams.pem" ]; then - openssl dhparam -out %{_sysconfdir}/letsencrypt/ssl-dhparams.pem 2048 + # Create ssl dh params if not already exists + if [ ! -f "%{_sysconfdir}/letsencrypt/ssl-dhparams.pem" ]; then + openssl dhparam -out %{_sysconfdir}/letsencrypt/ssl-dhparams.pem 2048 + fi fi # Restart services