
# must export this variable from shell no config yet

if [ "$TCOS_ENABLE_BOOTCHARTD" = "1" ]; then

  cpifexists $TCOS_BINS/tcos-bootchartd     /sbin
  cpifexists /bin/sleep                     /bin

  cat << EOF > $DESTDIR/sbin/bootlogger
#!/bin/sh
cmd="\$1"
logfile="\$2"

while [ -f "/tmp/bootchart.lock" ]; do
	# Write the time (in jiffies).
	read uptime < /proc/uptime
	uptime=\${uptime%% [0-9]*}
	uptime=\${uptime%.*}\${uptime#*.}
	echo \$uptime

	# Log the command output
	eval \$cmd 2>/dev/null
	echo
	/bin/sleep 0.2
done  >> "\$logfile"

EOF
  chmod +x $DESTDIR/sbin/bootlogger


  cat << EOF > $DESTDIR/scripts/init-top/000bootchartd
#!/bin/sh
#
if [ "\$1" = "prereqs" ]; then
  exit 0
fi

if grep -q bootchartd /proc/cmdline ; then
 /sbin/daemonize.sh /sbin/tcos-bootchartd start 
fi

EOF

  chmod +x $DESTDIR/scripts/init-top/000bootchartd
  
fi
