diff --git a/README.md b/README.md index a63e798..1046364 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,11 @@ systemd units for renew certificates acquired via acme.sh The timer unit should be enabled. +**Note: User units are not tested** ## How to use 1. `mkdir -pm 0700 /{etc,var/log}/acme.sh` - 2. `add LOG_FILE=/var/log/acme.sh/acme.sh.log` - -3. `# acme.sh --home /etc/acme.sh command ...[parameters]....` +3. `mv system/* -t /etc/systemd/system` or `mv user/* -t "${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user"` +4. `#systemctl enable acme.sh.timer` or `systemctl --user enable acme.sh.timer` +5. `# acme.sh --home /etc/acme.sh command...` or `$ acme.sh command...` diff --git a/acme.sh.service b/system/acme.sh.service similarity index 100% rename from acme.sh.service rename to system/acme.sh.service diff --git a/acme.sh.timer b/system/acme.sh.timer similarity index 100% rename from acme.sh.timer rename to system/acme.sh.timer diff --git a/user/acme.sh.service b/user/acme.sh.service new file mode 100644 index 0000000..af2e05c --- /dev/null +++ b/user/acme.sh.service @@ -0,0 +1,17 @@ +[Unit] +Description=Renew certificates acquired via acme.sh +After=network.target network-online.target nss-lookup.target +Wants=network-online.target nss-lookup.target +Documentation=https://https://github.com/acmesh-official/acme.sh/wiki + +[Service] +# If the version of systemd is 240 or above, then uncommenting Type=simple and commenting out Type=exec +#Type=exec +Type=simple +# The --home argument should be the location of the acme.sh configuration directory. +# This is the user unit, by default there is no need to set the --home folder +#ExecStart=/usr/bin/acme.sh --cron --home %h/.acme.sh +ExecStart=/usr/bin/acme.sh --cron +# acme.sh returns 2 when renewal is skipped (i.e. certs up to date) +SuccessExitStatus=0 2 +Restart=on-failure diff --git a/user/acme.sh.timer b/user/acme.sh.timer new file mode 100644 index 0000000..a57c7c7 --- /dev/null +++ b/user/acme.sh.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Run acme.sh daily + +[Timer] +OnCalendar=*-*-* 00:00:00 +Persistent=true + +[Install] +WantedBy=timers.target