Kaynağa Gözat

Merge branch 'master' of github.com:profplump/UberZach-Video

Zachary Kotlarek 12 yıl önce
ebeveyn
işleme
ac87989f5d
3 değiştirilmiş dosya ile 61 ekleme ve 2 silme
  1. 1 1
      backup/sync.sh
  2. 58 0
      backup/syncAll.sh
  3. 2 1
      mountMedia

+ 1 - 1
sync.sh → backup/sync.sh

@@ -11,7 +11,7 @@ if [ -z "${BASE_LOCAL}" ]; then
 	BASE_LOCAL="`~/bin/video/mediaPath`"
 fi
 if [ -z "${BASE_REMOTE}" ]; then
-	BASE_REMOTE="/Volumes/Bitcasa Infinite Drive"
+	BASE_REMOTE="/Volumes/webdav.opendrive.com"
 fi
 
 # Command-line arguments

+ 58 - 0
backup/syncAll.sh

@@ -0,0 +1,58 @@
+#!/bin/bash
+
+# Config
+SYNC_BIN="${HOME}/bin/video/backup/sync.sh"
+
+# Bail silently if ~/.archive_disable exists
+if [ -e ~/.archive_disable ]; then
+	exit 0
+fi
+
+# Ensure we have a valid TMPDIR
+if [ ! -d "${TMPDIR}" ]; then
+        TMPDIR="`getconf DARWIN_USER_TEMP_DIR 2>/dev/null`"
+        if [ ! -d "${TMPDIR}" ]; then
+                TMPDIR="/var/tmp"
+        fi
+        if [ ! -d "${TMPDIR}" ]; then
+                TMPDIR="/tmp"
+        fi
+fi
+
+# Bail if we're already running
+PID_FILE="${TMPDIR}/syncAll.pid"
+touch "${PID_FILE}"
+read SYNC_PID < "${PID_FILE}"
+if [ -n "${SYNC_PID}" ] && ps -A -o pid | grep -q "${SYNC_PID}"; then
+	exit 0
+else
+	echo $$ > "${PID_FILE}"
+fi
+
+# Fast updates for previously-synced paths
+
+# Slower updates for recently added paths
+"${SYNC_BIN}" Backups 5
+"${SYNC_BIN}" DMX 10
+"${SYNC_BIN}" iTunes/iTunes\ Music 10
+"${SYNC_BIN}" School 10
+"${SYNC_BIN}" Movies 5
+"${SYNC_BIN}" TV 5
+"${SYNC_BIN}" YouTube 50
+
+# If iPhoto is available, copy to Bitcasa
+MOUNTED=0
+if [ ! -d /Volumes/iPhoto ]; then
+	MOUNTED=1
+	hdiutil attach -readonly /mnt/media/Pictures/iPhoto.sparsebundle >/dev/null 2>&1
+fi
+if [ -d /Volumes/iPhoto ]; then
+	BASE_LOCAL="/Volumes/iPhoto" "${SYNC_BIN}" Shared.photolibrary 1000
+	if [ $MOUNTED -gt 0 ]; then
+		hdiutil detach /Volumes/iPhoto >/dev/null 2>&1
+	fi
+fi
+
+# Always exit cleanly
+rm -f "${PID_FILE}"
+exit 0

+ 2 - 1
mountMedia

@@ -13,6 +13,7 @@ fi
 
 # Config
 HOST="vera.uberzach.com"
+TIMEOUT=10
 SHARE="media"
 LOCK="${TMPDIR}/mountMedia.mounting"
 REMOTE_USER="${USER}"
@@ -75,7 +76,7 @@ if [ $LOCAL_LINK -eq 0 ] && ~/bin/video/isMediaMounted; then
 fi
 
 # Check for connectivity and server live-ness
-if ! ~/bin/video/timeout -t 2 nc -z "${HOST}" 139 >/dev/null 2>&1; then
+if ! ~/bin/video/timeout -t "${TIMEOUT}" nc -z "${HOST}" 139 >/dev/null 2>&1; then
 	echo "`basename "${0}"`: Host not available: ${HOST}" 1>&2
 	OFFLINE=1
 fi