Fix ADC sampling
[matches/MCTX3420.git] / server / run.sh
1 #!/bin/bash
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
5 #./stream &
6
7 # Check running as root
8 if [ "$(whoami)" != "root" ]; then
9         (echo "Run $0 as root.") 1>&2
10         exit 1
11 fi
12
13 # Check existence of program
14 if [ ! -e "server" ]; then
15         (echo "Rebuild server.") 1>&2;
16         exit 1
17 fi
18
19 # Identify cape-manager slots
20 slot=$(echo /sys/devices/bone_capemgr.*/slots | awk '{print $1}')
21
22 # Load PWM module
23 modprobe pwm_test
24 (echo am33xx_pwm > $slot) 1>&2 >> /dev/null
25
26 # Load ADCs
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))
31
32
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"

UCC git Repository :: git.ucc.asn.au