diff options
author | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2014-08-20 13:23:57 +0000 |
---|---|---|
committer | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2014-08-20 13:23:57 +0000 |
commit | ae6ae1f507ea76e6f9fa4e1ae1dba4aa14493aaa (patch) | |
tree | 61b86fd5cb1767487a49c7c5cc92b275817027cd /usr.sbin/rcctl | |
parent | c4bb450fafed6d3d9ce1618b34e35985c40a05ee (diff) |
Drop default values from rc.conf.local when we run "enable".
Diffstat (limited to 'usr.sbin/rcctl')
-rwxr-xr-x | usr.sbin/rcctl/rcctl.sh | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/usr.sbin/rcctl/rcctl.sh b/usr.sbin/rcctl/rcctl.sh index 41d325f75e0..9dca58ab92d 100755 --- a/usr.sbin/rcctl/rcctl.sh +++ b/usr.sbin/rcctl/rcctl.sh @@ -61,11 +61,31 @@ svc_default_enabled() svc_is_enabled ${_svc} && _ret=0 # reparse _all_ values - svc_is_base ${_svc} && _rc_parse_conf + _rc_parse_conf return ${_ret} } +svc_default_flags() +{ + local daemon_flags + local _svc=$1 + [ -n "${_svc}" ] || return + + # get _defaults_ values only + _rc_parse_conf /etc/rc.conf + + if svc_is_base ${_svc} || svc_is_special ${_svc}; then + svc_get_flags ${_svc} + else + eval $(grep '^daemon_flags=' /etc/rc.d/${_svc}) + echo ${daemon_flags} + fi + + # reparse _all_ values + _rc_parse_conf +} + svc_get_all() { local _i @@ -224,8 +244,10 @@ add_flags() set -A _flags -- ${_flags} fi elif svc_is_enabled ${_svc}; then - # svc is already enabled and we did not (re)set the flags - return + # we did not (re)set the flags: stop here if svc is already + # enabled and our current flags do not match the default ones; + # if they do, we drop the default "svc_flags=" further down + [[ "$(svc_default_flags ${_svc})" != "$(svc_get_flags ${_svc})" ]] && return fi # special var @@ -254,7 +276,8 @@ add_flags() rcconf_edit_begin grep -v "^${_svc}_flags.*=" /etc/rc.conf.local >${_TMP_RCCONF} if [ "${#_flags[*]}" -gt 0 ]; then - echo ${_svc}_flags=${_flags[@]} >>${_TMP_RCCONF} + [[ "${_flags[@]}" != "$(svc_default_flags ${_svc})" ]] && \ + echo ${_svc}_flags=${_flags[@]} >>${_TMP_RCCONF} fi rcconf_edit_end } |