commit 4d5c7130fe90d2482a2f4ee48eeb419f3c808b06
parent 8755e11128eee526fe1e81445682b4595208ad68
Author: Daniel Moch <daniel@danielmoch.com>
Date: Sun, 22 Apr 2018 18:28:19 -0400
Make cron scripts selectable
Diffstat:
6 files changed, 100 insertions(+), 99 deletions(-)
diff --git a/.local/bin/my b/.local/bin/my
@@ -350,7 +350,7 @@ case $command in
*:"$HOME/.local/bin":*) ;;
*) PATH="$HOME/.local/bin:$PATH" ;;
esac
- cronpath="$HOME/.local/lib/cron"
+ cronpath="$HOME/.local/lib/cron.d"
logpath="$HOME/.local/var/log"
for job in $cronpath/*
do
diff --git a/.local/bin/my-init b/.local/bin/my-init
@@ -193,6 +193,7 @@ done
[ -d "$HOME/.dotfiles" ] && cp "$HOME/.local/lib/dotfiles/pre-push" "$HOME/.dotfiles/.git/hooks/"
[ ! -d "$HOME/.local/var/log" ] && mkdir -p "$HOME/.local/var/log"
[ ! -d "$HOME/.local/var/forecastio" ] && mkdir -p "$HOME/.local/var/forecastio"
+[ ! -d "$HOME/.local/lib/cron.d" ] && mkdir -p "$HOME/.local/lib/cron.d"
[ ! -f "$HOME/.local/var/forecastio/current_forecast.txt" ] && echo \
"Weather not available" > \
"$HOME/.local/var/forecastio/current_forecast.txt"
diff --git a/.local/lib/cron.avail/cloudsync.sh b/.local/lib/cron.avail/cloudsync.sh
@@ -0,0 +1,98 @@
+#!/bin/sh
+#
+# ~/.local/lib/cron.avail/cloudsync.sh
+#
+
+echo "Beginning cloud sync at `date`"
+
+year=`date '+%Y'`
+month=`date '+%m'`
+lastrun_dir="$HOME/.local/var/`basename $0`"
+lastrun_file="$lastrun_dir/lastrun"
+mobile_docs="$HOME/Documents/Mobile"
+server_fqdn="nextcloud.djmoch.org"
+
+if [ -d "$lastrun_dir" ]
+then
+ if [ -f "$lastrun_file" ]
+ then
+ lastrun_year=`cat $lastrun_file | cut -d ' ' -f 1`
+ lastrun_month=`cat $lastrun_file | cut -d ' ' -f 2`
+ else
+ firstrun=1
+ fi
+else
+ firstrun=1
+ mkdir -p "$lastrun_dir"
+fi
+echo "$year $month" > $lastrun_file
+
+[ ! -d "$mobile_docs" ] && mkdir -p "$mobile_docs"
+
+# Only do the following if the server is reachable
+if ping -c 1 $server_fqdn > /dev/null 2>&1
+then
+ echo "$server_fqdn reachable. Proceeding."
+else
+ echo "$server_fqdn NOT reachable. Exiting."
+ exit -1
+fi
+
+if type -p xdg-user-dir > /dev/null 2>&1
+then
+ LOCAL_PHOTOS=`xdg-user-dir PICTURES`
+else
+ LOCAL_PHOTOS="$HOME/Pictures"
+fi
+
+# Mount the WebDAV folder and set so only we can read it
+if mount /mnt/nextcloud
+then
+ echo "NextCloud WebDAV successfully mounted. Setting permissions."
+ chmod 700 /mnt/nextcloud
+
+ # Rsync from WebDAV to ~/Photos
+ echo "Syncing Photos from WebDAV to $LOCAL_PHOTOS"
+ [ ! -d $LOCAL_PHOTOS/$year/$month ] && mkdir -p $LOCAL_PHOTOS/$year/$month
+ rsync -aq /mnt/nextcloud/Photos/$year/$month/* $LOCAL_PHOTOS/$year/$month
+ if [ -z "$firstrun" -a $lastrun_month -ne $month ]
+ then
+ # TODO: What if we're more than a month behind?
+ if [ ! -d $LOCAL_PHOTOS/$lastrun_year/$lastrun_month ]
+ then
+ mkdir -p $LOCAL_PHOTOS/$lastrun_year/$lastrun_month
+ fi
+ rsync -aq /mnt/nextcloud/Photos/$lastrun_year/$lastrun_month/* $LOCAL_PHOTOS/$lastrun_year/$lastrun_month
+ fi
+
+ # Rsync from ~/Photos to WebDAV
+ echo "Syncing Photos from $LOCAL_PHOTOS to WebDAV"
+ [ ! -d /mnt/nextcloud/Photos/$year/$month ] && mkdir -p /mnt/nextcloud/Photos/$year/$month
+ rsync -aq $LOCAL_PHOTOS/$year/$month/* /mnt/nextcloud/Photos/$year/$month
+ if [ -z "$firstrun" -a $lastrun_month -ne $month ]
+ then
+ if [ ! -d /mnt/nextcloud/Photos/$lastrun_year/$lastrun_month ]
+ then
+ mkdir -p /mnt/nextcloud/Photos/$lastrun_year/$lastrun_month
+ fi
+ # TODO: What if we're more than a month behind?
+ rsync -aq $LOCAL_PHOTOS/$lastrun_year/$lastrun_month/* /mnt/nextcloud/Photos/$lastrun_year/$lastrun_month
+ fi
+
+ # Rsync from WebDAV to ~/Documents/Mobile
+ echo "Syncing mobile documents from WebDAV to $mobile_docs"
+ rsync -aq /mnt/nextcloud/Documents/* "$mobile_docs"
+
+ # Rsync from ~/Documents/Mobile to WebDAV
+ echo "Syncing mobile documents from $mobile_docs to WebDAV"
+ rsync -aq "$mobile_docs"/* /mnt/nextcloud/Documents
+
+ # Finish by unmounting the WebDAV folder
+ echo "Unmounting $server_fqdn"
+ umount /mnt/nextcloud
+else
+ echo "NextCloud WebDAV mount FAILED. Exiting."
+ exit -2
+fi
+
+echo "Completed cloud sync at `date`"
diff --git a/.local/lib/cron/vdirsyncer.sh b/.local/lib/cron.avail/vdirsyncer.sh
diff --git a/.local/lib/cron/weather.sh b/.local/lib/cron.avail/weather.sh
diff --git a/.local/lib/cron/cloudsync.sh b/.local/lib/cron/cloudsync.sh
@@ -1,98 +0,0 @@
-#!/bin/sh
-#
-# ~/.local/lib/cron/cloudsync.sh
-#
-
-echo "Beginning cloud sync at `date`"
-
-year=`date '+%Y'`
-month=`date '+%m'`
-lastrun_dir="$HOME/.local/var/`basename $0`"
-lastrun_file="$lastrun_dir/lastrun"
-mobile_docs="$HOME/Documents/Mobile"
-server_fqdn="nextcloud.djmoch.org"
-
-if [ -d "$lastrun_dir" ]
-then
- if [ -f "$lastrun_file" ]
- then
- lastrun_year=`cat $lastrun_file | cut -d ' ' -f 1`
- lastrun_month=`cat $lastrun_file | cut -d ' ' -f 2`
- else
- firstrun=1
- fi
-else
- firstrun=1
- mkdir -p "$lastrun_dir"
-fi
-echo "$year $month" > $lastrun_file
-
-[ ! -d "$mobile_docs" ] && mkdir -p "$mobile_docs"
-
-# Only do the following if the server is reachable
-if ping -c 1 $server_fqdn > /dev/null 2>&1
-then
- echo "$server_fqdn reachable. Proceeding."
-else
- echo "$server_fqdn NOT reachable. Exiting."
- exit -1
-fi
-
-if type -p xdg-user-dir > /dev/null 2>&1
-then
- LOCAL_PHOTOS=`xdg-user-dir PICTURES`
-else
- LOCAL_PHOTOS="$HOME/Pictures"
-fi
-
-# Mount the WebDAV folder and set so only we can read it
-if mount /mnt/nextcloud
-then
- echo "NextCloud WebDAV successfully mounted. Setting permissions."
- chmod 700 /mnt/nextcloud
-
- # Rsync from WebDAV to ~/Photos
- echo "Syncing Photos from WebDAV to $LOCAL_PHOTOS"
- [ ! -d $LOCAL_PHOTOS/$year/$month ] && mkdir -p $LOCAL_PHOTOS/$year/$month
- rsync -aq /mnt/nextcloud/Photos/$year/$month/* $LOCAL_PHOTOS/$year/$month
- if [ -z "$firstrun" -a $lastrun_month -ne $month ]
- then
- # TODO: What if we're more than a month behind?
- if [ ! -d $LOCAL_PHOTOS/$lastrun_year/$lastrun_month ]
- then
- mkdir -p $LOCAL_PHOTOS/$lastrun_year/$lastrun_month
- fi
- rsync -aq /mnt/nextcloud/Photos/$lastrun_year/$lastrun_month/* $LOCAL_PHOTOS/$lastrun_year/$lastrun_month
- fi
-
- # Rsync from ~/Photos to WebDAV
- echo "Syncing Photos from $LOCAL_PHOTOS to WebDAV"
- [ ! -d /mnt/nextcloud/Photos/$year/$month ] && mkdir -p /mnt/nextcloud/Photos/$year/$month
- rsync -aq $LOCAL_PHOTOS/$year/$month/* /mnt/nextcloud/Photos/$year/$month
- if [ -z "$firstrun" -a $lastrun_month -ne $month ]
- then
- if [ ! -d /mnt/nextcloud/Photos/$lastrun_year/$lastrun_month ]
- then
- mkdir -p /mnt/nextcloud/Photos/$lastrun_year/$lastrun_month
- fi
- # TODO: What if we're more than a month behind?
- rsync -aq $LOCAL_PHOTOS/$lastrun_year/$lastrun_month/* /mnt/nextcloud/Photos/$lastrun_year/$lastrun_month
- fi
-
- # Rsync from WebDAV to ~/Documents/Mobile
- echo "Syncing mobile documents from WebDAV to $mobile_docs"
- rsync -aq /mnt/nextcloud/Documents/* "$mobile_docs"
-
- # Rsync from ~/Documents/Mobile to WebDAV
- echo "Syncing mobile documents from $mobile_docs to WebDAV"
- rsync -aq "$mobile_docs"/* /mnt/nextcloud/Documents
-
- # Finish by unmounting the WebDAV folder
- echo "Unmounting $server_fqdn"
- umount /mnt/nextcloud
-else
- echo "NextCloud WebDAV mount FAILED. Exiting."
- exit -2
-fi
-
-echo "Completed cloud sync at `date`"