diff --git a/tubesync/restart_services.sh b/tubesync/restart_services.sh index 3c1d981bb..c8e934808 100755 --- a/tubesync/restart_services.sh +++ b/tubesync/restart_services.sh @@ -6,37 +6,32 @@ svc_path() ( realpath -e -s "$@" ) -_bundles="$( - find '/etc/s6-overlay/s6-rc.d' -mindepth 2 -maxdepth 2 \ - -name 'type' \ - -execdir grep -F -q -e bundle '{}' ';' \ - -printf '%P\n' | \ - sed -e 's,/type$,,' ; -)" -is_a_bundle() { - local bundle - for bundle in ${_bundles} +is_a_longrun() { + if [ 'longrun' = "$(/command/s6-rc-db type "$1")" ] + then + return 0 + fi + return 1 +} +only_longruns() { + local service + for service in "$@" do - if [ "$1" = "${bundle}" ] + if is_a_longrun "${service}" then - return 0 + printf -- '%s\n' "${service}" fi done - return 1 } if [ 0 -eq $# ] then - set -- $(/command/s6-rc list user | grep -v -e '-init$') + set -- $(only_longruns $(/command/s6-rc -e -a list)) fi for arg in "$@" do - _svcs="${arg}" - if is_a_bundle "${arg}" - then - _svcs="$(/command/s6-rc list "${arg}" | grep -v -e '-init$')" - fi + _svcs="$(only_longruns $(/command/s6-rc -e list "${arg}"))" for service in $(svc_path ${_svcs}) do printf -- 'Restarting %-28s' "${service#${_dir}/}..." @@ -47,5 +42,4 @@ do "$( expr "${_ended}" - "${_began}" )" done done -unset -v _began _ended _svcs arg service -unset -v _bundles _dir +unset -v _began _dir _ended _svcs arg service