Permalink
Browse files

[feature] synchronization can be configured to run only while on AC

  • Loading branch information...
marook committed Apr 30, 2012
1 parent d178e0a commit e0955342930e2a5dd56f77d1b59ff72d57167b31
Showing with 17 additions and 1 deletion.
  1. +17 −1 sharefs.sh
View
@@ -2,10 +2,21 @@
set -e
+#==========================================================================
# the following constants can be overwritten in configuration files
+
ENCFS_OPTS=--standard
+
RSYNC_OPTS=-az
+# flags whether synchronization should be executed while on battery power
+# 0: only sync while on AC
+# 1: always sync
+SYNC_ON_BATTERY=0
+
+# end of constants
+#==========================================================================
+
fail()
{
echo "$1" >&2
@@ -153,7 +164,12 @@ case "$1" in
echo "$BASHPID" > "$pidFile"
- rsync $RSYNC_OPTS -e ssh "$dataDir" "$remoteDst"
+ if [ "$SYNC_ON_BATTERY" == '1' -o `cat "/sys/class/power_supply/AC/online"` == "1" ]
+ then
+ rsync $RSYNC_OPTS -e ssh "$dataDir" "$remoteDst"
+ else
+ echo "Not synchronizing while on battery."
+ fi
cleanup
;;

0 comments on commit e095534

Please sign in to comment.