Skip to content

Instantly share code, notes, and snippets.

@abythell
Last active December 15, 2015 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abythell/5339014 to your computer and use it in GitHub Desktop.
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.
#!/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