Last active
December 15, 2015 23:19
-
-
Save abythell/5339014 to your computer and use it in GitHub Desktop.
A script to download, build, and install CamDate, a Java application built using libgphoto2-jna. CamDate sets the current system time to the current time on a USB-attached camera.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Automatically download, build, and install CamDate, a tool | |
# to set the System Time on a Raspberry Pi using a gphoto2-suppored | |
# camera. | |
# | |
# | |
# Check if root | |
# | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root/sudo" | |
exit -1 | |
fi | |
# | |
# Check Camera is attached and supported | |
# | |
apt-get update | |
apt-get install gphoto2 | |
gphoto2 --get-config datetime | |
if [ $? -ne 0 ]; then | |
echo "Camera not detected or does not support remote." | |
exit -1 | |
fi | |
# | |
# Install pre-requisites for building and running CamDate | |
# | |
apt-get install libgphoto2-2 openjdk-7-jdk libjna-java git ant | |
# | |
# Build CamDate from latest source | |
# | |
git clone https://github.com/angryelectron/libgphoto2-jna.git | |
cd libgphoto2-jna/examples/camdate | |
ant jar | |
# | |
# Install and configure to run automatically on boot | |
# | |
mkdir -p /opt/camdate | |
cp -rf dist/* /opt/camdate/. | |
sed -i '/^exit 0/i\#Set Time from Camera\n(cd /opt/camdate; java -jar camdate.jar)\n' /etc/rc.local |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment