From 3b85dc5119a85533a6e5b847f927c15e13e6c024 Mon Sep 17 00:00:00 2001 From: Cameron Ball Date: Tue, 24 Mar 2015 08:39:10 +0000 Subject: [PATCH] Quick and easy update scripts. Update readme. --- .gitignore | 2 ++ README.md | 10 ++++++++++ config.ini => config.ini.example | 5 ++--- start.sh | 7 +++++++ usb-config.sh | 30 ++++++++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 3 deletions(-) rename config.ini => config.ini.example (76%) create mode 100755 start.sh create mode 100755 usb-config.sh diff --git a/.gitignore b/.gitignore index af2bfd7..14a8b53 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *.o hdmi-switcher +video.mp4 +config.ini diff --git a/README.md b/README.md index 1f58d3c..65ddc53 100644 --- 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). diff --git a/config.ini b/config.ini.example similarity index 76% rename from config.ini rename to config.ini.example index c46ee0f..3d6c71b 100644 --- a/config.ini +++ b/config.ini.example @@ -1,3 +1,2 @@ -[global] -credit_value=10 ; How many seconds inserting a credit adds to the timer - +[global] +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 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 index 0000000..8d89ad4 --- /dev/null +++ b/usb-config.sh @@ -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 -- 2.11.0