2 # Use this to quickly test run the server in valgrind
3 #spawn-fcgi -p9005 -n ./valgrind.sh
4 # Use this to run the server normally
7 # Check running as root
8 if [ "$(whoami)" != "root" ]; then
9 (echo "Run $0 as root.") 1>&2
13 # Check existence of program
14 if [ ! -e "server" ]; then
15 (echo "Rebuild server.") 1>&2;
19 # Identify cape-manager slots
20 slot=$(echo /sys/devices/bone_capemgr.*/slots | awk '{print $1}')
24 (echo am33xx_pwm > $slot) 1>&2 >> /dev/null
27 (echo cape-bone-iio > $slot) 1>&2 >> /dev/null
28 # Find adc_device_path
29 # NOTE: This has to be passed as a parameter, because it is not always the same. For some unfathomable reason. Hooray.
30 adc_device_path=$(dirname $(find /sys -name *AIN0))
33 # Run the program with parameters
34 # TODO: Can tell spawn-fcgi to run the program as an unprivelaged user?
35 # But first will have to work out how to set PWM/GPIO as unprivelaged user
36 spawn-fcgi -p9005 -n -- ./server -a "$adc_device_path"