#!/bin/sh
ROYALE_DIR=/royale_exp
export LD_LIBRARY_PATH=$ROYALE_DIR

echo "performance" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# echo "performance" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
# echo "performance" > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
# echo "performance" > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor
# echo "performance" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor
# echo "performance" > /sys/devices/system/cpu/cpu5/cpufreq/scaling_governor
# echo "performance" > /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor
# echo "performance" > /sys/devices/system/cpu/cpu7/cpufreq/scaling_governor

while [ 1 ]; do
	ps -a | grep -v grep | grep "sample2" > /dev/null
	result=$?
	if [ "${result}" -ne "0" ]; then
		echo "Starting Artik Camera Capture Service"
		$ROYALE_DIR/sample2
	fi

	sleep 0.1
done
