From 0732fbcdbf941aee7771ea586534c7f92d40a95c Mon Sep 17 00:00:00 2001 From: Stanislav Seletskiy Date: Mon, 25 Apr 2016 16:03:19 +0600 Subject: [PATCH] docopt: new flags and formatting --- main.go | 59 +++++++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/main.go b/main.go index ae00d77..dd17ecb 100644 --- a/main.go +++ b/main.go @@ -6,8 +6,14 @@ import ( "github.com/docopt/docopt-go" ) +const version = "1.0" + const usage = `orgalorg - synchronizing files on many hosts. +First of all, orgalorg will try to acquire global cluster lock by flock'ing +root directory on each host. If at least one flock fails, then orgalorg +will stop, unless '-k' flag is specified. + orgalorg will create tar-archive from specified files, keeping file attributes and ownerships, then upload archive in parallel to the specified hosts and unpacks it in the temporary directory. No further actions will be done until @@ -25,7 +31,7 @@ actions). All output from guntalina will be passed back and returned on stdout. Finally, all temporary files will be removed from hosts, optionally keeping -backup of the modified files on every host. +backup of the modified files on every host, and global lock is freed. Restrictions: @@ -34,48 +40,51 @@ Restrictions: Usage: orgalorg -h | --help - orgalorg [options] (-d |-f |-o )... -S ... + orgalorg [options] (-d |-f |-o |-s)... + -S ... Required options: -o Target host in format [@][:]. -f File to read target hosts from. One host per line. - Format for one record same as for flag '-o'. + Format for one record same as for flag '-o'. -d Directory to read hosts file from. It's OK to store - symlinks to real files in that directory. + symlinks to real files in that directory. + -s Read hosts from stdin in addition to other flags. Options: -h --help Show this help. -n Dry run: upload files on hosts and run gunter in dry - run mode. No real files will be replaced. Temporary - files will be deleted. Guntalina will be launched in - dry mode too. - -b Do backup of modified files on each target host. - WARNING: no backup will be done by default! + run mode. No real files will be replaced. Temporary + files will be deleted. Guntalina will be launched in + dry mode too. + -b Do not backup of modified files on each target host. -i Identity file (private key), which will be used for - authentication. - [default: ~/.ssh/id_rsa] + authentication. + [default: ~/.ssh/id_rsa] -p Use password authentication. Password will be - requested on stdin after program start. - Excludes '-i' option. + requested on stdin after program start. + Excludes '-i' option. -x Do not try to obtain root (via 'sudo -i'). - By default, orgalorg will try to obtain root and do - all actions from root, because it's most common use - case. To prevent that behaviour, this option can be - used. + By default, orgalorg will try to obtain root and do + all actions from root, because it's most common use + case. To prevent that behaviour, this option can be + used. + -k Try to obtain global lock, but only print warning if + it cannot be done, do not stop execution. -v Print debug information on stderr. -V Print program version. Advanced options: --backups-dir Directory, that will be used on the remote hosts for - storing backups. Backups will be stored in the - subdirectory, uniquely named with source hostname - and timestamp. - This option is only useful with '-b', which is off - by default. - [default: /var/orgalorg/backups/] + storing backups. Backups will be stored in the + subdirectory, uniquely named with source hostname + and timestamp. + This option is only useful with '-b', which is off + by default. + [default: /var/orgalorg/backups/] --temp-dir Use specified directory for storing temporary data - on each host. - [default: /tmp/orgalorg/runs/] + on each host. + [default: /tmp/orgalorg/runs/] ` func main() {