Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Deoccupy root's crontab #634

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions misc/cron/bluecherry-subdomain-cert-renewal
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file is a part of bluecherry package.

# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
* * */5 * * root /usr/share/bluecherry/subdomain-cert-renewal &>/dev/null
*/5 * * * * root curl -k https://localhost:7001/subdomainprovidercron >/dev/null 2>&1

# vim: syntax=crontab
4 changes: 3 additions & 1 deletion misc/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,9 @@ case "$1" in
/usr/local/bin/pip3 install pyopenssl --upgrade

# Install crontabs for subdomain renewal and SSL renewal using certbot
crontab -l 2>/dev/null || true; printf "* * */5 * * certbot renew --config-dir=/usr/share/bluecherry/nginx-includes/letsencrypt/ >/dev/null 2>&1\n*/5 * * * * curl -k https://localhost:7001/subdomainprovidercron >/dev/null 2>&1\n" | crontab -
install --mode 600 cron/bluecherry-subdomain-cert-renewal /etc/cron.d
# Clean root's crontab from entries which we previously put there
crontab -l 2>/dev/null | grep -v 'bluecherry\|subdomainprovidercron' | crontab -


nginx -t 2>/dev/null > /dev/null
Expand Down
13 changes: 13 additions & 0 deletions misc/subdomain-cert-renewal
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -euo pipefail

# Suppress the output of the rest of the script.
# To debug, redirect to a real file.
exec &> /dev/null

CERTBOT=/root/.local/bin/certbot
if ! [[ -x "$CERTBOT" ]]; then
CERTBOT=certbot
fi

"$CERTBOT" renew --config-dir=/usr/share/bluecherry/nginx-includes/letsencrypt/
13 changes: 9 additions & 4 deletions scripts/update_subdomain_certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,16 @@ chmod 600 $credentials
# Generate certificates
echo "Generating certs..."

certbot certonly --non-interactive --agree-tos --work-dir=/tmp --logs-dir=/tmp \
CERTBOT=/root/.local/bin/certbot
if ! [[ -x "$CERTBOT" ]]; then
CERTBOT=certbot
fi

"$CERTBOT" certonly --non-interactive --agree-tos --work-dir=/tmp --logs-dir=/tmp \
--config-dir=/usr/share/bluecherry/nginx-includes/letsencrypt/ \
--dns-subdomain-provider-credentials $credentials \
-m $email --authenticator dns-subdomain-provider \
-d $subdomain.bluecherry.app -v
--dns-subdomain-provider-credentials "$credentials" \
-m "$email" --authenticator dns-subdomain-provider \
-d "$subdomain".bluecherry.app -v

rm $credentials

Expand Down
Loading