#!/bin/sh /etc/rc.common
START=35

enable() {
	name="$(basename "${initscript}")"
	ln -sf "/etc/init.d/$name" "$IPKG_INSTROOT/etc/rc1.d/S${START}${name##S[0-9][0-9]}"
}



start() {
	{ [ -f /etc/config/cron ] && grep thinclient /etc/config/cron >/dev/null; } || {
		h=$(expr $(head -c2 /dev/urandom | hexdump -d | awk '$2 > 0 {print $2}') % 24)
		m=$(expr $(head -c2 /dev/urandom | hexdump -d | awk '$2 > 0 {print $2}') % 60)
		echo "$m $h * * * /bin/thinclient cron" >> /etc/config/cron
	}
	[ -e /etc/crontabs/root ] || ln -sf /etc/config/cron /etc/crontabs/root
	mkdir -p /tmp/.ssh
	cp /etc/dropbear/known_hosts /tmp/.ssh
	/bin/thinclient start
}
