File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22#
33# 2012-2019 Nico Schottelius (nico-cdist at schottelius.org)
44# 2013 Daniel Heule (hda at sfs.biz)
5+ # 2025 Dennis Camera (dennis.camera at riiengineering.ch)
56#
67# This file is part of skonfig-base.
78#
9697 state=' absent'
9798 service -e | grep " /${name} $" && state=' present'
9899 ;;
100+ (netbsd)
101+ NL=$( printf ' \n.' ) ; NL=${NL% ?}
102+
103+ if test -x /usr/sbin/service
104+ then
105+ # NetBSD >= 7.0
106+ rcvar=$( /usr/sbin/service " ${name} " rcvar)
107+ else
108+ # NetBSD < 7.0
109+ rc_script=$(
110+ # shellcheck source=/dev/null
111+ . /etc/rc.conf
112+ for _d in ${rc_directories:-/ etc/ rc.d}
113+ do
114+ if test -f " ${_d} /${name} " && test -x " ${_d} /${name} "
115+ then
116+ printf ' %s/%s\n' " ${_d} " " ${name} "
117+
118+ fi
119+ done)
120+ test -x " ${rc_script} " || {
121+ printf ' service %s could not be found' " ${name} " >&2
122+ exit 1
123+ }
124+
125+ rcvar=$( " ${rc_script} " rcvar)
126+ fi
127+
128+ # remove service name comment
129+ rcvar=${rcvar# ' #' * " ${NL} " }
130+ # only first variable (at the time of writing there can’t be more
131+ # than one anyway)
132+ rcvar=${rcvar%% " ${NL} " * }
133+ # some (older) versions of NetBSD prefix the rcvar with $
134+ rcvar=${rcvar# \$ }
135+
136+ case ${rcvar}
137+ in
138+ (* =* )
139+ # OK
140+ extra=${rcvar%% =* }
141+
142+ case ${rcvar#* =}
143+ in
144+ ([Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
145+ state=' present' ;;
146+ (* )
147+ state=' absent' ;;
148+ esac
149+ ;;
150+ (' ' )
151+ # this service is not enableable
152+ printf ' The service %s is not enableable\n' " ${name} " >&2
153+ exit 1
154+ ;;
155+ esac
156+ ;;
99157 (openbsd)
100158 state=' absent'
101159 # OpenBSD 5.7 and higher
109167 esac
110168fi
111169
112- echo " ${state} "
170+ printf ' %s%s\n ' " ${state} " " ${extra : + ${extra} }"
Original file line number Diff line number Diff line change 2121#
2222
2323state_should=$( cat " ${__object:? } /parameter/state" )
24- state_is= $( cat " ${__object:? } /explorer/state" )
24+ read -r state_is _ < " ${__object:? } /explorer/state" || :
2525init=$( cat " ${__global:? } /explorer/init" )
2626target_runlevel=$( cat " ${__object:? } /parameter/target_runlevel" )
2727
6262 ;;
6363
6464
65- (freebsd)
66- : # handled in manifest
65+ (freebsd|netbsd )
66+ # handled in manifest
6767 ;;
6868
6969 (openbsd)
104104 echo " '/etc/init.d/${name} ' disable"
105105 ;;
106106
107+
108+ (freebsd|netbsd)
109+ # handled in manifest
110+ ;;
111+
107112 (openbsd)
108113 # OpenBSD 5.7 and higher
109114 echo " rcctl disable '${name} '"
Original file line number Diff line number Diff line change 22#
33# 2018 Kamila Součková (kamila at ksp.sk)
44# 2018 Jonas Weber (github at jonasw.de)
5+ # 2025 Dennis Camera (dennis.camera at riiengineering.ch)
56#
67# This file is part of skonfig-base.
78#
1920# along with skonfig-base. If not, see <http://www.gnu.org/licenses/>.
2021#
2122
22- state_should=$( cat " ${__object:? } /parameter/state" )
23- state_is=$( cat " ${__object:? } /explorer/state" )
2423name=${__object_id:? }
2524
25+ state_should=$( cat " ${__object:? } /parameter/state" )
26+ read -r state_is extra < " ${__object:? } /explorer/state" || :
27+
2628# Short circuit if nothing is to be done
2729[ " ${state_should} " = " ${state_is} " ] && exit 0
2830
4345 --value " \" ${value} \" " \
4446 --delimiter ' ='
4547 ;;
48+ (netbsd)
49+ rcvar=${extra}
50+ : " ${rcvar:? rcvar detection failed} "
51+ __key_value " /etc/rc.conf:${rcvar} " \
52+ --file /etc/rc.conf \
53+ --delimiter ' =' --exact_delimiter \
54+ --key " ${rcvar} " \
55+ --value " $(
56+ case ${state_should}
57+ in
58+ (present)
59+ echo YES ;;
60+ (absent)
61+ echo NO ;;
62+ esac)"
63+ ;;
4664 (*)
47- : # handled in gencode-remote
65+ # handled in gencode-remote
4866 ;;
4967esac
You can’t perform that action at this time.
0 commit comments