Browse Source

Finish generalizing

cryobry 3 years ago
parent
commit
a99eefd7e5
4 changed files with 15 additions and 13 deletions
  1. 6 3
      install.sh
  2. 1 1
      original.service
  3. 7 8
      original.sh
  4. 1 1
      original.timer

+ 6 - 3
install.sh

@@ -24,8 +24,9 @@
 debug="off" # turn "on" for debugging
 # IMPORTANT OPTIONS #
 service_name="rsync-to-picture-frame" # use something specific and memorable
-frame_address="192.168.1.100:2221" # you can find this on the frame, best to make static
-source_dir="$HOME/Pictures/picture_frame" # source pictures/content from this directory
+description="Mount picture frame ftp share and rsync syncthing picture_frame directory to it" # a short description
+ftp_share="192.168.1.100:2221" # source share, best to make this a static address if you can
+source_dir="$HOME/Pictures/picture_frame" # source files from this directory
 # Less important options
 user="$(id -un)" # default run as current user
 user_id="$(id -u)" # default run as current user
@@ -156,7 +157,7 @@ main() {
   make_exec "$script_dir/$service_name.sh"
   f_and_r "{{mount_dir}}" "$mount_dir" "$script_dir/$service_name.sh"
   f_and_r "{{source_dir}}" "$source_dir" "$script_dir/$service_name.sh"
-  f_and_r "{{frame_address}}" "$frame_address" "$script_dir/$service_name.sh"
+  f_and_r "{{ftp_share}}" "$ftp_share" "$script_dir/$service_name.sh"
   f_and_r "{{user_id}}" "$user_id" "$script_dir/$service_name.sh"
   f_and_r "{{group_id}}" "$group_id" "$script_dir/$service_name.sh"
   f_and_r "{{temp_dir}}" "$temp_dir" "$script_dir/$service_name.sh"
@@ -164,10 +165,12 @@ main() {
   # Copy service file
   cp_file "original.service" "$service_dir/$service_name.service"
   f_and_r "{{path_to_script}}" "$script_dir/$service_name.sh" "$service_dir/$service_name.service"
+  f_and_r "{{description}}" "$script_dir/$service_name.sh" "$service_dir/$service_name.service"
 
   # Copy timer file
   cp_file "original.timer" "$service_dir/$service_name.timer"
   f_and_r "{{on_calendar}}" "$on_calendar" "$service_dir/$service_name.timer"
+  f_and_r "{{description}}" "$description" "$service_dir/$service_name.timer"
 
   # Enable timer
   debug "systemctl --user daemon-reload"

+ 1 - 1
original.service

@@ -1,5 +1,5 @@
 [Unit]
-Description="Mount picture frame ftp and rsync photo directory"
+Description="{{description}}}}"
 After=network-online.target
 Wants=network-online.target
 

+ 7 - 8
original.sh

@@ -1,6 +1,5 @@
 #!/usr/bin/env bash
-# This script will mount mom's photo frame ftp share locally
-# Use install.sh to change settings
+# Use install.sh to edit settings
 
 # if the mount already exists, unmount it
 mountpoint -q -- "{{mount_dir}}" && fusermount -u "{{mount_dir}}"
@@ -9,7 +8,7 @@ mountpoint -q -- "{{mount_dir}}" && fusermount -u "{{mount_dir}}"
 [[ ! -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 curlftpfs -o uid="{{user_id}}",gid="{{group_id}}" "{{ftp_share}}" "{{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
@@ -19,14 +18,14 @@ if curlftpfs -o uid="{{user_id}}",gid="{{group_id}}" "{{frame_address}}" "{{moun
     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"
+  echo "Could not mount ftp share"
+  if ping -c 1 "{{ftp_share}}"; then
+    echo "Ping OK, check the ftp device settings or the local filesystem permissions"
     exit 1
   else
-    echo "Could not ping the photo frame, is it on?"
+    echo "Could not ping the device, is it on?"
     exit 1
   fi
 fi
 
-exit $?
+exit $?

+ 1 - 1
original.timer

@@ -1,5 +1,5 @@
 [Unit]
-Description="Transfer photos to picture frame hourly"
+Description="{{description}}"
 
 [Timer]
 OnBootSec=1min