mirror of
https://github.com/dehydrated-io/dehydrated.git
synced 2026-01-11 22:30:44 +01:00
Dependency on HOME which may not be set #27
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @samueldr on GitHub (Dec 31, 2015).
The current script uses
${HOME}, when in some cases it might not be set in the environment. The use case where it happens is using letsencrypt.sh as a systemd service/timer set.This causes this issue:
As this is used to find plausible config file locations, I wouldn't know what's the best way to avoid this issue. The
${HOME}location might be important for some cases, for mine it isn't.As a stop-gap solution (for anybody setting up a systemd timer), it can be set explicitly.
Personally, I would use
~instead of${HOME}which does always resolve to the current user's home, even when neither${HOME}or${USER}are in the environment. There is one caveat with the use of~, its properties around quoting are different than those of variables. I have not tested with a folder with spaces as a home folder, but I would guess that it would be even rarer than an execution of the script with a barebones environment. I think that with the current use, the quoting would still be fine, as long as it is used like so, unquoted:~/.letsencrypt.sh.Here's a test case:
/usr/local/bin/tildeexpansion.shTo run as a systemd service:
/etc/systemd/system/tildeexpansion.serviceIt can be run with
sudo systemctl daemon-reload; sudo systemctl start tildeexpansion./usr/local/bin/tildeexpansion.shneeds to be executable. The output can be looked at usingsudo journalctl --unit tildeexpansion. This test case service will fail since the exit code of the script is a failure.References:
@lukas2511 commented on GitHub (Jan 8, 2016):
I completely removed using the config from a home directory in
ff11639624, but thanks for explaining the workaround.Users who still want to use this can add an alias to their shells config to call the script with
--config /path/to/config.