confz

git mirror of https://ccx.te2000.cz/bzr/confz
git clone https://ccx.te2000.cz/git/confz
Log | Files | Refs

commit 8132a6a37da5416eaa83e2f78b856f6187b901af
parent 298c2e4110b8cc2e121a308399ef6b4afe56f9ab
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date:   Tue, 24 Jun 2014 10:16:53 +0200

basic openrc support
Diffstat:
Azsh-functions/confz_openrc_init | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+), 0 deletions(-)

diff --git a/zsh-functions/confz_openrc_init b/zsh-functions/confz_openrc_init @@ -0,0 +1,54 @@ +# vim: ft=zsh noet ts=4 sts=4 sw=4 + +# +# confz functions for OpenRC +# + +typeset -g confz_openrc_runlevel +typeset -ga confz_openrc_runlevel_deps + +# find explicit dependencies of OpenRC runlevel +confz_openrc_runlevel_find_deps() { + [[ -d /etc/runlevels/$1 ]] || die "$0: no such runlevel: ${(qqq)1}" + confz_openrc_runlevel_deps+=( $1 ) + local d + for d in /etc/runlevels/$1/*(N-/); do + confz_openrc_runlevel_find_deps $d:A:t + done +} + +# get the current OpenRC runlevel +confz_openrc_get_runlevel() { + confz_openrc_runlevel=$(</run/openrc/softlevel) || return $? + confz_openrc_runlevel_find_deps $confz_openrc_runlevel || return $? + # implicit dependencies + case $confz_openrc_runlevel in + (sysinit|shutdown) + ;; + (boot) + confz_openrc_runlevel_find_deps sysinit || return $?;; + (*) + confz_openrc_runlevel_find_deps sysinit || return $? + confz_openrc_runlevel_find_deps boot || return $?;; + esac +} + +# check if OpenRC service is started +confz_openrc_started_check() { + checkvars service + do_command=( /etc/init.d/${vars[service]} start ) + + /etc/init.d/${vars[service]} status -q +} + +# check if all the services in current and depending runlevels are started +confz_openrc_runlevel_fully_started_check() { + confz_openrc_get_runlevel || die "couldn't determine OpenRC runlevel" + local runlevel service + for runlevel in $confz_openrc_runlevel_deps; do + for service in /etc/runlevels/$runlevel/*(N-.); do + require openrc_started $service:t + done + done + do_command=( true ) +}