Quick and easy update scripts. Update readme.
authorCameron Ball <c.ball1729@gmail.com>
Tue, 24 Mar 2015 08:39:10 +0000 (08:39 +0000)
committerCameron Ball <c.ball1729@gmail.com>
Tue, 24 Mar 2015 08:39:10 +0000 (08:39 +0000)
.gitignore
README.md
config.ini.example [moved from config.ini with 76% similarity]
start.sh [new file with mode: 0755]
usb-config.sh [new file with mode: 0755]

index af2bfd7..14a8b53 100644 (file)
@@ -1,2 +1,4 @@
 *.o
 hdmi-switcher
+video.mp4
+config.ini
index 1f58d3c..65ddc53 100644 (file)
--- a/README.md
+++ b/README.md
@@ -10,3 +10,13 @@ The pin numbers can be confusing. If you hold the Pi such that the GPIO header i
 Pin 7 needs to be shorted to pin 9 for the magic to happen.
 
 Run ./hdmi-switcher as root, or using sudo.
+
+Script Automation
+=================
+The scripts assume the following:
+- An fstab entry for /dev/sda1 pointing to /mnt/usb-config
+- Binary and scripts live in /home/pi/hdmi-switcher
+
+The usb-config script will naively look to see if /dev/sda1 exists. If it does, it mounts it and then copies over any files on the drive with names config.ini, video.mp4
+
+If you want to run the script on boot, you should use start.sh. start.sh runs the usb-config scripts, and then starts playing video.mp4 on a loop. It uses omxplayer (make sure whatever version you use has the --loop option).
similarity index 76%
rename from config.ini
rename to config.ini.example
index c46ee0f..3d6c71b 100644 (file)
@@ -1,3 +1,2 @@
-[global]
-credit_value=10              ; How many  seconds inserting a credit adds to the timer
-
+[global]\r
+credit_value=10              ; How many  seconds inserting a credit adds to the timer
\ No newline at end of file
diff --git a/start.sh b/start.sh
new file mode 100755 (executable)
index 0000000..0cb29c7
--- /dev/null
+++ b/start.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+/home/pi/hdmi-switcher/usb-config.sh
+printf "Starting video... "
+sleep 5
+printf "OK\n"
+omxplayer --loop --no-osd -b -p -o hdmi /home/pi/hdmi-switcher/video.mp4 > /dev/null 2>&1
+clear
diff --git a/usb-config.sh b/usb-config.sh
new file mode 100755 (executable)
index 0000000..8d89ad4
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+clear
+
+if [[ ! -e "/dev/sda1" ]]; then
+ exit 1
+fi
+
+printf "Found USB... "
+
+umount /dev/sda1 > /dev/null 2>&1
+mount /dev/sda1 > /dev/null 2>&1 || (printf "Mount failure\n" && exit 1)
+
+printf "Mount OK\n"
+
+set -e
+
+if [[ -e "/mnt/usb-config/config.ini" ]]; then
+  printf "Found config.ini... "
+  cp /mnt/usb-config/config.ini /home/pi/hdmi-switcher || (printf "Copy failure\n" && exit 0)
+  printf "Copy OK\n"
+fi
+
+if [[ -e "/mnt/usb-config/video.mp4" ]]; then
+  printf "Found video.mp4... "
+  cp /mnt/usb-config/video.mp4 /home/pi/hdmi-switcher || (printf "Copy failure\n" && exit 0)
+  printf "Copy OK\n"
+fi
+
+umount /dev/sda1 > /dev/null 2>&1