From: ajacoutot Date: Wed, 20 Aug 2014 13:23:56 +0000 (+0000) Subject: Drop default values from rc.conf.local when we run "enable". X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=68006144604f51ac40b1e50d38ddcd4ccd303353;p=openbsd Drop default values from rc.conf.local when we run "enable". --- diff --git a/usr.sbin/rcctl/rcctl.sh b/usr.sbin/rcctl/rcctl.sh index 41d325f75e0..9dca58ab92d 100644 --- 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 }