mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-08 21:23:48 -05:00
bump version. Add support for roots in Unison prf files.
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
# Source my scripting utils
|
#!/usr/bin/env bash
|
||||||
# ------------------------
|
|
||||||
|
|
||||||
# ##################################################
|
# ##################################################
|
||||||
# My Generic sync script.
|
# My Generic sync script.
|
||||||
@@ -25,8 +24,12 @@
|
|||||||
# destroys your data, crashes your car, or otherwise causes mayhem
|
# destroys your data, crashes your car, or otherwise causes mayhem
|
||||||
# and destruction. USE AT YOUR OWN RISK.
|
# and destruction. USE AT YOUR OWN RISK.
|
||||||
#
|
#
|
||||||
|
VERSION="1.1"
|
||||||
|
#
|
||||||
# HISTORY
|
# HISTORY
|
||||||
# * 2015-01-02 - First Creation
|
# * 2015-01-03 - v.1.1 - Added version number
|
||||||
|
# - Added support for using roots in Unison .prf
|
||||||
|
# * 2015-01-02 - v.1.0 - First Creation
|
||||||
#
|
#
|
||||||
# ##################################################
|
# ##################################################
|
||||||
|
|
||||||
@@ -116,13 +119,15 @@ function configFile() {
|
|||||||
# ##################################################
|
# ##################################################
|
||||||
# CONFIG FILE FOR $SCRIPTNAME
|
# CONFIG FILE FOR $SCRIPTNAME
|
||||||
# CREATED ON $NOW
|
# CREATED ON $NOW
|
||||||
|
#
|
||||||
|
# Created by version "$VERSION" of "$SCRIPTNAME"
|
||||||
# ##################################################
|
# ##################################################
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# BASE CONFIGURATION
|
# BASE CONFIGURATION
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
|
||||||
# Method
|
# METHOD
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# This script will work with both Unison and rsync.
|
# This script will work with both Unison and rsync.
|
||||||
# Set the METHOD variable to either 'unison' or 'rsync'
|
# Set the METHOD variable to either 'unison' or 'rsync'
|
||||||
@@ -168,9 +173,10 @@ TARGETDIRECTORY=""
|
|||||||
# If you wish to use a Unison profile change USERPROFILE to 'true'
|
# If you wish to use a Unison profile change USERPROFILE to 'true'
|
||||||
# and add the profile name to UNISONPROFILE.
|
# and add the profile name to UNISONPROFILE.
|
||||||
#
|
#
|
||||||
# Note: Roots should not be included in the UNISON prf. They will be called here
|
# If your Unison profile contains the 'roots' to by synced, change PROFILEROOTS to 'true'.
|
||||||
# using the SOURCE/TARGET variables
|
# If this remains 'false', the directories to by synced will be the ones specified above.
|
||||||
USEPROFILE="false"
|
USEPROFILE="false"
|
||||||
|
PROFILEROOTS="false"
|
||||||
UNISONPROFILE=""
|
UNISONPROFILE=""
|
||||||
|
|
||||||
|
|
||||||
@@ -314,12 +320,31 @@ function mainScript() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$USEPROFILE" != "true" ]; then
|
# Run Unison
|
||||||
# Run Unison without a profile
|
if [ "$PROFILEROOTS" = "true" ]; then
|
||||||
unison "$SOURCEDIRECTORY" "$TARGETDIRECTORY"
|
# Throw error if we don't have enough information
|
||||||
|
if [ "$USEPROFILE" = "false" ] || [ "$UNISONPROFILE" = "" ]; then
|
||||||
|
echo "$NOW - We were missing the Unison Profile. Could not sync." >> "$LOGFILE"
|
||||||
|
die "We were missing the Unison Profile. Could not sync."
|
||||||
|
fi
|
||||||
|
# Run unison with the profile
|
||||||
|
echo "$NOW - Beginning Unison Sync" >> "$LOGFILE"
|
||||||
|
unison "$UNISONPROFILE"
|
||||||
else
|
else
|
||||||
|
if [ "$USEPROFILE" = "true" ]; then
|
||||||
|
# Throw error if we can't find the profile
|
||||||
|
if [ "$UNISONPROFILE" = "" ]; then
|
||||||
|
echo "$NOW - We were missing the Unison Profile. Could not sync." >> "$LOGFILE"
|
||||||
|
die "We were missing the Unison Profile. Could not sync."
|
||||||
|
fi
|
||||||
# Run unison with a profile
|
# Run unison with a profile
|
||||||
|
echo "$NOW - Beginning Unison Sync" >> "$LOGFILE"
|
||||||
unison "$UNISONPROFILE" "$SOURCEDIRECTORY" "$TARGETDIRECTORY"
|
unison "$UNISONPROFILE" "$SOURCEDIRECTORY" "$TARGETDIRECTORY"
|
||||||
|
else
|
||||||
|
# Run Unison without a profile
|
||||||
|
echo "$NOW - Beginning Unison Sync" >> "$LOGFILE"
|
||||||
|
unison "$SOURCEDIRECTORY" "$TARGETDIRECTORY"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user