diff options
-rw-r--r-- | CHANGELOG.md | 4 | ||||
-rw-r--r-- | lib/util/svc.bash | 2 |
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 |