[Rear-users] SF.net SVN: rear:[575] trunk/usr

jhoekx at users.sourceforge.net jhoekx at users.sourceforge.net
Tue Jun 7 12:30:29 CEST 2011


Revision: 575
          http://rear.svn.sourceforge.net/rear/?rev=575&view=rev
Author:   jhoekx
Date:     2011-06-07 10:30:29 +0000 (Tue, 07 Jun 2011)

Log Message:
-----------
Make the help and checklayout workflow lockless. Do not overwrite logfile.

Modified Paths:
--------------
    trunk/usr/sbin/rear
    trunk/usr/share/rear/conf/default.conf
    trunk/usr/share/rear/lib/checklayout-workflow.sh
    trunk/usr/share/rear/lib/help-workflow.sh

Modified: trunk/usr/sbin/rear
===================================================================
--- trunk/usr/sbin/rear	2011-06-07 00:29:00 UTC (rev 574)
+++ trunk/usr/sbin/rear	2011-06-07 10:30:29 UTC (rev 575)
@@ -110,6 +110,21 @@
 	exit 1
 fi
 
+# set some bash options
+shopt -s nullglob extglob
+hash -r
+
+# make sure that we use only english
+export LC_CTYPE=C LC_ALL=C LANG=C
+
+# include default config
+. $SHARE_DIR/conf/default.conf
+
+# include functions
+for script in $SHARE_DIR/lib/*.sh ; do
+	. $script
+done
+
 # get full path to main script
 SCRIPT_FILE="$(readlink -f $(type -p "$0" || echo "$0"))"
 
@@ -119,30 +134,17 @@
 fi
 
 # do not run if another instance is running. pidof -x will always report at least $$
-if [ $$ != "$(pidof -x "$SCRIPT_FILE")" ] ; then
+if ! IsInArray "$WORKFLOW" "${LOCKLESS_WORKFLOWS}" && [ $$ != "$(pidof -x "$SCRIPT_FILE")" ] ; then
 	echo "ERROR: $SCRIPT_FILE is already running, not starting again" >&2
 	exit 1
 fi
 
-# set some bash options
-shopt -s nullglob extglob
-hash -r
-
-# make sure that we use only english
-export LC_CTYPE=C LC_ALL=C LANG=C
-
-# include default config
-. $SHARE_DIR/conf/default.conf
-
-
+if IsInArray "$WORKFLOW" "${LOCKLESS_WORKFLOWS[@]}" ; then
+	LOGFILE="$LOGFILE.lockless"
+fi
 test -r "$LOGFILE" && mv -f "$LOGFILE" "$LOGFILE".old 2>/dev/null # keep old log file
 exec 2>"$LOGFILE" || echo "ERROR: Could not create $LOGFILE" 1>&2
 
-# include functions
-for script in $SHARE_DIR/lib/*.sh ; do
-	. $script
-done
-
 LogPrint "$PRODUCT Version $VERSION / $RELEASE_DATE"
 Log "Command line options: $0 ${CMD_OPTS[@]}"
 

Modified: trunk/usr/share/rear/conf/default.conf
===================================================================
--- trunk/usr/share/rear/conf/default.conf	2011-06-07 00:29:00 UTC (rev 574)
+++ trunk/usr/share/rear/conf/default.conf	2011-06-07 10:30:29 UTC (rev 575)
@@ -75,6 +75,8 @@
 
 # no default workflows. This variable is filled in where the worklflows are defined
 WORKFLOWS=( )
+# allow some workflows to not take the ReaR lock, also generates a separate log
+LOCKLESS_WORKFLOWS=( )
 
 # default backup and output targets
 BACKUP=REQUESTRESTORE

Modified: trunk/usr/share/rear/lib/checklayout-workflow.sh
===================================================================
--- trunk/usr/share/rear/lib/checklayout-workflow.sh	2011-06-07 00:29:00 UTC (rev 574)
+++ trunk/usr/share/rear/lib/checklayout-workflow.sh	2011-06-07 10:30:29 UTC (rev 575)
@@ -20,9 +20,10 @@
 
 WORKFLOW_checklayout_DESCRIPTION="Check if the disk layout has changed since the last run of savelayout."
 WORKFLOWS=( ${WORKFLOWS[@]} checklayout )
+LOCKLESS_WORKFLOWS=( ${LOCKLESS_WORKFLOWS[@]} checklayout )
 WORKFLOW_checklayout () {
     ORIG_LAYOUT=$VAR_DIR/layout/disklayout.conf
-    TEMP_LAYOUT=$VAR_DIR/layout/disklayout.conf.new
+    TEMP_LAYOUT=$TMP_DIR/checklayout.conf
 
     SourceStage "layout/precompare"
     

Modified: trunk/usr/share/rear/lib/help-workflow.sh
===================================================================
--- trunk/usr/share/rear/lib/help-workflow.sh	2011-06-07 00:29:00 UTC (rev 574)
+++ trunk/usr/share/rear/lib/help-workflow.sh	2011-06-07 10:30:29 UTC (rev 575)
@@ -18,6 +18,7 @@
 #
 #
 
+LOCKLESS_WORKFLOWS=( ${LOCKLESS_WORKFLOWS[@]} help )
 WORKFLOW_help () {
 	cat <<EOF
 $SCRIPT_FILE [Options] <command> [command options ...]


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rear-users mailing list