Compare commits

...

3 Commits

Author SHA1 Message Date
d7d87e0162 feat: add skip certbot option
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-04 06:38:58 +02:00
48792673dc fix: use absolute path in service file 2026-03-15 18:21:11 +01:00
d8b747e315 fix: make install rights
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-03-15 16:43:26 +01:00
4 changed files with 39 additions and 28 deletions

View File

@@ -73,8 +73,8 @@ install: ## Install files into rpm dest (requires env var DESTDIR)
printf "[CRITICAL] Missing env var DESTDIR\n[CRITICAL] This command is designed to be called by rpmbuild only!\n" 1>&2; \ printf "[CRITICAL] Missing env var DESTDIR\n[CRITICAL] This command is designed to be called by rpmbuild only!\n" 1>&2; \
exit 1; \ exit 1; \
fi fi
install --directory $(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d $(DESTDIR)$(RPM_SYSCONFDIR)/certbot $(DESTDIR)$(RPM_UNITDIR) $(DESTDIR)$(RPM_SBINDIR) install --mode=755 --directory $(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d $(DESTDIR)$(RPM_SYSCONFDIR)/certbot $(DESTDIR)$(RPM_UNITDIR) $(DESTDIR)$(RPM_SBINDIR)
install --mode=755 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d files/nginx/0_security.conf files/nginx/z_default.conf install --mode=644 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d files/nginx/0_security.conf files/nginx/z_default.conf
install --mode=600 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/certbot files/certbot/ovh.ini install --mode=600 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/certbot files/certbot/ovh.ini
install --mode=644 --target-directory=$(DESTDIR)$(RPM_UNITDIR) files/systemd/certbot-renew.service files/systemd/certbot-renew.timer install --mode=644 --target-directory=$(DESTDIR)$(RPM_UNITDIR) files/systemd/certbot-renew.service files/systemd/certbot-renew.timer
install --mode=755 --target-directory=$(DESTDIR)$(RPM_SBINDIR) files/sbin/certbot_renew install --mode=755 --target-directory=$(DESTDIR)$(RPM_SBINDIR) files/sbin/certbot_renew

View File

@@ -48,15 +48,16 @@ A `Makefile` is integrated to let you run some basic commands.
Two workflows are set up. Two workflows are set up.
- Continuous Integration: - Continuous Integration:
- triggered by each push on branch `main` - triggered by each push event on branch `main`
- runs shellcheck on script `certbot_renew` - runs shellcheck
- builds tarball and rpm package to test everything is OK - builds tarball
- builds rpm package
- Continuous Delivery: - Continuous Delivery:
- triggered by each tag pushed - triggered by each tag push event
- builds tarball - builds tarball
- builds and uploads rpm package to `Gitea` repository - builds rpm package
- uploads rpm package to repository
# Deployment # Deployment
@@ -97,6 +98,11 @@ Some commands to deploy the RPM package on server
set +a set +a
``` ```
- Install or upgrade without certbot (for testing environment)
```shell
SKIP_CERTBOT=true dnf --nogpgcheck --refresh --assumeyes --best install netoik-rp
```
# Security Notes # Security Notes

View File

@@ -2,4 +2,4 @@
Description=Renew certbot certificates Description=Renew certbot certificates
[Service] [Service]
ExecStart=certbot_renew ExecStart=/usr/sbin/certbot_renew

View File

@@ -22,30 +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 if [ -z $OVH_ENDPOINT ]; then echo "Missing env var OVH_ENDPOINT!" 1>&2; exit 1; fi
if cmp --silent %{_sysconfdir}/certbot/.ovh.ini.new %{_sysconfdir}/certbot/ovh.ini; then if [ -z $OVH_APPLICATION_NAME ]; then echo "Missing env var OVH_APPLICATION_KEY!" 1>&2; exit 1; fi
rm %{_sysconfdir}/certbot/.ovh.ini.new if [ -z $OVH_APPLICATION_DESCRIPTION ]; then echo "Missing env var OVH_APPLICATION_DESCRIPTION!" 1>&2; exit 1; fi
else 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 fi
# Create ssl dh params if not already exists # Create ssl dh params if not already exists
if [ ! -f "%{_sysconfdir}/letsencrypt/ssl-dhparams.pem" ]; then if [ ! -f "%{_sysconfdir}/letsencrypt/ssl-dhparams.pem" ]; then
openssl dhparam -out %{_sysconfdir}/letsencrypt/ssl-dhparams.pem 2048 openssl dhparam -out %{_sysconfdir}/letsencrypt/ssl-dhparams.pem 2048
fi
fi fi
# Restart services # Restart services