confz_openrc_init (1483B)
1 # vim: ft=zsh noet ts=4 sts=4 sw=4 2 3 # 4 # confz functions for OpenRC 5 # 6 7 typeset -g confz_openrc_runlevel 8 typeset -ga confz_openrc_runlevel_deps 9 10 # find explicit dependencies of OpenRC runlevel 11 confz_openrc_runlevel_find_deps() { 12 [[ -d /etc/runlevels/$1 ]] || die "$0: no such runlevel: ${(qqq)1}" 13 confz_openrc_runlevel_deps+=( $1 ) 14 local d 15 for d in /etc/runlevels/$1/*(N-/); do 16 confz_openrc_runlevel_find_deps $d:A:t 17 done 18 } 19 20 # get the current OpenRC runlevel 21 confz_openrc_get_runlevel() { 22 confz_openrc_runlevel=$(</run/openrc/softlevel) || return $? 23 confz_openrc_runlevel_find_deps $confz_openrc_runlevel || return $? 24 # implicit dependencies 25 case $confz_openrc_runlevel in 26 (sysinit|shutdown) 27 ;; 28 (boot) 29 confz_openrc_runlevel_find_deps sysinit || return $?;; 30 (*) 31 confz_openrc_runlevel_find_deps sysinit || return $? 32 confz_openrc_runlevel_find_deps boot || return $?;; 33 esac 34 } 35 36 # check if OpenRC service is started 37 confz_openrc_started_check() { 38 checkvars service 39 do_command=( /etc/init.d/${vars[service]} start ) 40 41 /etc/init.d/${vars[service]} status -q 42 } 43 44 # check if all the services in current and depending runlevels are started 45 confz_openrc_runlevel_fully_started_check() { 46 confz_openrc_get_runlevel || die "couldn't determine OpenRC runlevel" 47 local runlevel service 48 for runlevel in $confz_openrc_runlevel_deps; do 49 for service in /etc/runlevels/$runlevel/*(N-.); do 50 require openrc_started service=$service:t 51 done 52 done 53 do_command=( true ) 54 }