aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2022-05-11 10:28:43 +0200
committerPatrick Spek <p.spek@tyil.nl>2022-05-11 10:28:43 +0200
commitb3c98a0f9dae4eb1e6078df4a0c55a9e892ae56e (patch)
tree62b7d1ae60f045a4bc78f576936c5a6b2ac34ab1
parent6d89fa1486fc78a2ffa10f8ed927c8af3fbf181f (diff)
Check if rc.d file exists
-rw-r--r--CHANGELOG.md4
-rw-r--r--lib/util/svc.bash2
2 files changed, 4 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2be3885..4034fa7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,12 +8,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
-- `var` subcommand is now referenced in `usage`.
+- `var` subcommand is now referenced in `usage()`.
### Changed
- `ssh` subcommand should now only check for `ssh.host`, and show an appropriate
warning if one is not set for a node.
+- `svc_enable()` now checks for the `rc.d` file to exist before running `grep`
+ on it.
## [1.0.0] - 2022-05-06
diff --git a/lib/util/svc.bash b/lib/util/svc.bash
index 3a5f7b2..3b2ac90 100644
--- a/lib/util/svc.bash
+++ b/lib/util/svc.bash
@@ -53,7 +53,7 @@ svc_enable() {
freebsd)
rc="$(printf '%s_enable="YES"' "$service")"
- if ! grep -Fqx "$rc" "/etc/rc.conf.d/$service"
+ if [[ ! -f "/etc/rc.conf.d/$service" ]] || ! grep -Fqx "$rc" "/etc/rc.conf.d/$service"
then
printf "%s\n" "$rc" >> "/etc/rc.conf.d/$service"
fi