From 9b9d20380bc4f5222c013d685a0f6248484588ed Mon Sep 17 00:00:00 2001 From: cryobry <38270216+cryobry@users.noreply.github.com> Date: Mon, 13 Jul 2020 13:09:25 -0400 Subject: [PATCH] Add scripts back --- original.service | 10 ++++++++++ original.sh | 32 ++++++++++++++++++++++++++++++++ original.timer | 10 ++++++++++ 3 files changed, 52 insertions(+) create mode 100644 original.service create mode 100644 original.sh create mode 100644 original.timer diff --git a/original.service b/original.service new file mode 100644 index 0000000..0be12fa --- /dev/null +++ b/original.service @@ -0,0 +1,10 @@ +[Unit] +Description="Mount picture frame ftp and rsync photo directory" +After=network-online.target +Wants=network-online.target + +[Service] +ExecStart={{path_to_script}} + +[Install] +WantedBy=multi-user.target diff --git a/original.sh b/original.sh new file mode 100644 index 0000000..bcaffa2 --- /dev/null +++ b/original.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# This script will mount mom's photo frame ftp share locally +# Use install.sh to change settings + +# if the mount already exists, unmount it +mountpoint -q -- "{{mount_dir}}" && fusermount -u "{{mount_dir}}" + +# make temp directory (ftp does not support rsync temp files) +[[ ! -d "{{temp_dir}}" ]] && mkdir -p "{{temp_dir}}" + +# Mount it and rsync over the photos +if curlftpfs -o uid="{{user_id}}",gid="{{group_id}}" "{{frame_address}}" "{{mount_dir}}"; then + if ! rsync -r --delete --quiet --temp-dir="{{temp_dir}}" "{{source_dir}}/" "{{mount_dir}}"; then + echo "rsync -r --delete --quiet {{source_dir}}/ {{mount_dir}} failed!" + exit 1 + fi + if ! fusermount -u "{{mount_dir}}"; then + echo "Could not unmount {{mount_dir}}" + exit 1 + fi +else + echo "Could not mount Mom's picture frame" + if ping -c 1 "{{frame_address}}"; then + echo "Ping OK, check the photo frame settings or the filesystem" + exit 1 + else + echo "Could not ping the photo frame, is it on?" + exit 1 + fi +fi + +exit $? diff --git a/original.timer b/original.timer new file mode 100644 index 0000000..e26c5f0 --- /dev/null +++ b/original.timer @@ -0,0 +1,10 @@ +[Unit] +Description="Transfer photos to picture frame hourly" + +[Timer] +OnBootSec=1min +OnCalendar={{on_calendar}} +Persistent=true + +[Install] +WantedBy=timers.target