#!/usr/bin/sh

## We only want this to script to do things when s6-66 is detected
while [ $(ps -p1 | grep -ic "s6-svscan") -eq 1 ] && [ -e /run/66 ]; do
	export PATH=$PATH:/usr/sbin:/usr/lib/execline/bin:/usr/libexec
	trap '66 tree stop && 66 scandir remove && rm -rf /run/66/scandir/$(id -u) || sleep 5 && pkill -9 waitpid' EXIT TERM
	
	exec sh -c '
		trap "66 tree stop && 66 scandir remove && rm -rf /run/66/scandir/$(id -u) || sleep 5 && pkill -9 waitpid" EXIT TERM
		66 scandir check || bash -c "coproc 66 scandir start &"
		66 tree start &
		'
done & 
