-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpbstart
executable file
·72 lines (58 loc) · 2.9 KB
/
pbstart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
export SCRIPTSBASEDIR="/home/vloschiavo/src/vloradio"
. ${SCRIPTSBASEDIR}/config.sh
# Setup global variables for vloradio
# If $FIRSTBOOT is set in rc.local, then give the pi some time to start before launching, and display startup message
if [ "$FIRSTBOOT" == "1" ] ; then
# Give the Raspberry Pi plenty of time to boot before trying to start vloradio
# Read the current release name and version number into an array and print that.
. /etc/*-release; array=( $PRETTY_NAME )
${SCRIPTSBASEDIR}/DisplayLCDMessage.py "${array[0]} ${array[2]}" "...started." > /dev/null 2>&1
sleep 10
${SCRIPTSBASEDIR}/DisplayLCDMessage.py "Starting:" "...vLo Radio" > /dev/null 2>&1
export FIRSTBOOT=0
else
# This script ($0) isn't being called at boot by rc.local, so start normally
${SCRIPTSBASEDIR}/DisplayLCDMessage.py "Starting:" "...vLo Radio" > /dev/null 2>&1
fi
cd $PATIOBAR
if [ ! -p $CTLFILE ]; then
mkfifo $CTLFILE
fi
# Kill any old Patiobar processes running
/usr/local/bin/pbstop > /dev/null 2>&1
# Kill any old gpio-watch processes running
killall -g gpio-watch > /dev/null 2>&1
# Setup GPIO Pins and interrupts for push buttons
/usr/local/bin/gpio -g mode 4 in # Sets pin mode to input
/usr/local/bin/gpio -g mode 4 up # Sets internal pull-up resistor
/usr/local/bin/gpio -g mode 12 in
/usr/local/bin/gpio -g mode 12 up
/usr/local/bin/gpio -g mode 18 in
/usr/local/bin/gpio -g mode 18 up
/usr/local/bin/gpio -g mode 22 in
/usr/local/bin/gpio -g mode 22 up
/usr/local/bin/gpio -g mode 23 in
/usr/local/bin/gpio -g mode 23 up
/usr/local/bin/gpio -g mode 24 in
/usr/local/bin/gpio -g mode 24 up
/usr/local/bin/gpio-watch -e switch 4 12 18 22 23 24 & # Sets up an interrupt on pin 6 with the "switch" type
# Rotary Encoder handler script
${SCRIPTSBASEDIR}/PianobarVolumeEncoder.py &
#Start a screen session called 'pianobar' and launch the pianobar binary
/usr/bin/screen -S pianobar -d -m bash -c 'pianobar'
# Give gnu screen and pianobar some time to start up
# Patiobar requires that the files exist before it will start. Wait for eventcmd.sh to create them
# While the files don't exist, sleep 1 - once the both exist, then exit the loop
while [[ ! -f /var/tmp/currentSong || ! -f /var/tmp/stationList ]]
do
sleep 2
done
# Create a second window in the 'pianobar' screen and launch Patiobar (the web gui) in it
# Allow stdout and errors to print to this window
# The "patiobar" after index.js is used as an identifier so we can kill it when stopping.
/usr/bin/screen -S pianobar -X screen node $PATIOBAR/index.js patiobar
# Print some stuff to that same window of the 'pianobar' screen
/usr/bin/screen -S pianobar -p 1 -X stuff $'\r##############################################################\r'
/usr/bin/screen -S pianobar -p 1 -X stuff $"#Go to http://$(hostname):3000/ to launch the Web interface.\r"
/usr/bin/screen -S pianobar -p 1 -X stuff $'##############################################################\r'