Added daemon option to file monitor mode
This commit is contained in:
parent
bb7e4642d5
commit
486fcf7831
|
@ -21,6 +21,7 @@ KNOWN ISSUES
|
||||||
RECENT CHANGES
|
RECENT CHANGES
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
- Added possibility to daemonize osync in monitor mode
|
||||||
- Added monitor mode, which will launch a sync task upon file operations on master replica
|
- Added monitor mode, which will launch a sync task upon file operations on master replica
|
||||||
- Changed conf file default format for ssh uri (old format is still compatible)
|
- Changed conf file default format for ssh uri (old format is still compatible)
|
||||||
- Added ssh uri support for slave replicas
|
- Added ssh uri support for slave replicas
|
||||||
|
|
50
osync.sh
50
osync.sh
|
@ -3,7 +3,7 @@
|
||||||
###### Osync - Rsync based two way sync engine with fault tolerance
|
###### Osync - Rsync based two way sync engine with fault tolerance
|
||||||
###### (L) 2013 by Orsiris "Ozy" de Jong (www.netpower.fr)
|
###### (L) 2013 by Orsiris "Ozy" de Jong (www.netpower.fr)
|
||||||
OSYNC_VERSION=0.99RC2-qs
|
OSYNC_VERSION=0.99RC2-qs
|
||||||
OSYNC_BUILD=1811201303
|
OSYNC_BUILD=1811201304
|
||||||
|
|
||||||
DEBUG=no
|
DEBUG=no
|
||||||
SCRIPT_PID=$$
|
SCRIPT_PID=$$
|
||||||
|
@ -11,6 +11,13 @@ SCRIPT_PID=$$
|
||||||
LOCAL_USER=$(whoami)
|
LOCAL_USER=$(whoami)
|
||||||
LOCAL_HOST=$(hostname)
|
LOCAL_HOST=$(hostname)
|
||||||
|
|
||||||
|
if [ -w /var/run ]
|
||||||
|
then
|
||||||
|
PID_FILE=/var/run/osync_$SCRIPT_PID.run
|
||||||
|
else
|
||||||
|
PID_FILE=./osync_$SCRIPT_PID.run
|
||||||
|
fi
|
||||||
|
|
||||||
## Default log file until config file is loaded
|
## Default log file until config file is loaded
|
||||||
if [ -w /var/log ]
|
if [ -w /var/log ]
|
||||||
then
|
then
|
||||||
|
@ -1662,22 +1669,27 @@ function Main
|
||||||
function Usage
|
function Usage
|
||||||
{
|
{
|
||||||
echo "Osync $OSYNC_VERSION $OSYNC_BUILD"
|
echo "Osync $OSYNC_VERSION $OSYNC_BUILD"
|
||||||
|
echo "(C) 2013 by Orsiris \"Ozy\" de Jong"
|
||||||
|
echo "http://www.netpower.fr/osync"
|
||||||
echo ""
|
echo ""
|
||||||
echo "You may use Osync with a full blown configuration file, or use its default options for quick command line sync."
|
echo "You may use Osync with a full blown configuration file, or use its default options for quick command line sync."
|
||||||
echo "Normal usage: osync /path/to/conf.file [--dry] [--silent] [--verbose] [--no-maxtime] [--force-unlock]"
|
echo "Usage: osync /path/to/config/file [GENERAL OPTIONS]"
|
||||||
echo "Quick usage: osync --master=/path/to/master/replica --slave=/path/to/slave/replica [--rsakey=/path/to/id_rsa] [--dry] [--silent] [--verbose] [--no-max-time] [--force-unlock]"
|
echo "or osync --master=/path/to/master/replica --slave=/path/to/slave/replica [QUICKSYNC OPTIONS] [GENERAL OPTIONS]"
|
||||||
|
echo "or osync --master=/path/to/master/replica --slave=ssh://backupuser@remotehost.com[:portnumber]//path/to/slave/replica [QUICKSYNC OPTIONS] [GENERAL OPTIONS]"
|
||||||
echo ""
|
echo ""
|
||||||
echo "--dry: will run osync without actually doing anything; just testing"
|
echo "[GENERAL OPTIONS]"
|
||||||
echo "--silent: will run osync without any output to stdout, usefull for cron jobs"
|
echo "--dry Will run osync without actually doing anything; just testing"
|
||||||
echo "--verbose: adds command outputs"
|
echo "--silent Will run osync without any output to stdout, used for cron jobs"
|
||||||
echo "--no-maxtime: disables any soft and hard execution time checks"
|
echo "--verbose Increases output"
|
||||||
echo "--force-unlock: will override any existing active or dead locks on master and slave replica"
|
echo "--no-maxtime Disables any soft and hard execution time checks"
|
||||||
echo "--on-changes: will launch a sync as soon as there is some file activity on master replica."
|
echo "--force-unlock Will override any existing active or dead locks on master and slave replica"
|
||||||
|
echo "--on-changes Will launch a sync as soon as there is some file activity on master replica"
|
||||||
|
echo "--daemon When used with --on-changes, will launch osync as daemon."
|
||||||
echo ""
|
echo ""
|
||||||
echo "Quick usage only:"
|
echo "[QUICKSYNC OPTIONS]"
|
||||||
echo "--master= : Specify master replica path. Will contain state and backup directory."
|
echo "--master=\"\" Master replica path. Will contain state and backup directory"
|
||||||
echo "--slave= : Specify local or remote path for slave replica. Can be a ssh uri like ssh://user@host.com:22//path/to/slave/replica"
|
echo "--slave=\"\" Local or remote slave replica path. Can be a ssh uri like ssh://user@host.com:22//path/to/slave/replica"
|
||||||
echo "--rsakey= : Specify alternative path to rsa private key for ssh connection to slave replica."
|
echo "--rsakey=\"\" Alternative path to rsa private key for ssh connection to slave replica"
|
||||||
exit 128
|
exit 128
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1716,6 +1728,7 @@ error_alert=0
|
||||||
soft_stop=0
|
soft_stop=0
|
||||||
quick_sync=0
|
quick_sync=0
|
||||||
sync_on_changes=0
|
sync_on_changes=0
|
||||||
|
daemonize=0
|
||||||
osync_cmd=$0
|
osync_cmd=$0
|
||||||
|
|
||||||
if [ $# -eq 0 ]
|
if [ $# -eq 0 ]
|
||||||
|
@ -1760,6 +1773,9 @@ do
|
||||||
--on-changes)
|
--on-changes)
|
||||||
sync_on_changes=1
|
sync_on_changes=1
|
||||||
;;
|
;;
|
||||||
|
--daemon)
|
||||||
|
daemonize=1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -1781,7 +1797,13 @@ then
|
||||||
Init
|
Init
|
||||||
if [ $sync_on_changes -eq 1 ]
|
if [ $sync_on_changes -eq 1 ]
|
||||||
then
|
then
|
||||||
SyncOnChanges
|
if [ $daemonize -eq 1 ]
|
||||||
|
then
|
||||||
|
echo $SCRIPT_PID > $PID_FILE
|
||||||
|
silent=1
|
||||||
|
exec > /dev/null 2>&1
|
||||||
|
fi
|
||||||
|
SyncOnChanges &
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
DATE=$(date)
|
DATE=$(date)
|
||||||
|
|
Loading…
Reference in New Issue