#!/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
		bash -c "coproc 66 scandir start &" && sh -c "66 tree start"
		'
done & 
