From 9cd6bc1f924c574d45bffe59ac99a1674d2d830e Mon Sep 17 00:00:00 2001 From: Guten Ye Date: Thu, 12 Jun 2014 15:18:41 +0800 Subject: [PATCH] bugfix --- libexec/oldtime | 1 - libexec/oldtime-backup | 8 ++++---- libexec/oldtime-help | 2 +- libexec/oldtime-restore | 13 +++++++------ 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libexec/oldtime b/libexec/oldtime index d7e027f..366ae49 100755 --- a/libexec/oldtime +++ b/libexec/oldtime @@ -2,7 +2,6 @@ set -e export -n CDPATH - VERSION="2.0.0" if [ -n "$OLDTIME_DEBUG" ]; then diff --git a/libexec/oldtime-backup b/libexec/oldtime-backup index 6a264f6..413b7fa 100755 --- a/libexec/oldtime-backup +++ b/libexec/oldtime-backup @@ -5,7 +5,7 @@ # Usage: oldtime backup [options] [instance] [rsync_options] # # [OPTIONS] -# -d # oldtime config directory, default is /oldtime +# -c # oldtime config directory, default is /oldtime # # Default working directory is /oldtime/work. # @@ -13,7 +13,7 @@ # # oldtime backup hello # oldtime backup hello vm -# oldtime backup -d myoldtime hello --dry-run +# oldtime backup -c myoldtime hello --dry-run # set -e @@ -84,9 +84,9 @@ if [[ -z "$1" ]]; then exit 1 fi -while getopts "d:" opt; do +while getopts "c:" opt; do case $opt in - d ) OLDTIME_DIR=$OPTARG ;; + c ) OLDTIME_DIR=$OPTARG ;; esac done shift $(( OPTIND - 1 )) diff --git a/libexec/oldtime-help b/libexec/oldtime-help index 7ac27a2..3a7223e 100755 --- a/libexec/oldtime-help +++ b/libexec/oldtime-help @@ -110,7 +110,7 @@ print_help() { eval "$(documentation_for "$command")" [[ -n "$help" ]] || help="$summary" - if [[ -n "$usage" -o -n "$summary" ]]; then + if [[ -n "$usage" || -n "$summary" ]]; then if [[ -n "$usage" ]]; then echo "$usage" else diff --git a/libexec/oldtime-restore b/libexec/oldtime-restore index b2e7535..7865dac 100755 --- a/libexec/oldtime-restore +++ b/libexec/oldtime-restore @@ -5,14 +5,14 @@ # Usage: oldtime restore [options] [instance] [rsync_options] # # [OPTIONS] -# -d # oldtime config directory, default is /oldtime +# -c # oldtime config directory, default is /oldtime # # Default working directory is /oldtime/work. # # Examples: # # oldtime restore hello vm -# oldtime restore -d myoldtime hello vm --dry-run +# oldtime restore -c myoldtime hello vm --dry-run # set -e @@ -22,7 +22,7 @@ source "$OLDTIME_ROOT/libexec/lib.sh" source "$OLDTIME_ROOT/libexec/helpers.sh" invoke_rsync() { - end_cmd=$(sed "1s~\\$SRC~$SRC~;s~\\$DEST~$DEST~;q" "$1") + end_cmd=$(sed "1s~\$SRC~$SRC~;s~\$DEST~$DEST~;q" "$1") end_cmd=$(echo $end_cmd | awk '{print $2, $1}') cmd="$RESTORE_OPTIONS $RSYNC_OPTIONS $end_cmd" echo ">> rsync $cmd" @@ -51,9 +51,9 @@ if [[ -z "$1" ]]; then exit 1 fi -while getopts "d:" opt; do +while getopts "c:" opt; do case $opt in - d ) OLDTIME_DIR=$OPTARG ;; + c ) OLDTIME_DIR=$OPTARG ;; esac done shift $(( OPTIND - 1 )) @@ -61,13 +61,14 @@ shift $(( OPTIND - 1 )) profile="$1" instance="$2" conf="$OLDTIME_DIR/$profile.conf" -profile_dir=$(absolutename "$OLDTIME_DIR/$profile") if [[ ! -e "$conf" ]]; then echo "oldtime: config file doesn't exists -- $conf " >&2 exit 1 fi +profile_dir=$(absolutename "$OLDTIME_DIR/$profile") + [[ ! -d "$OLDTIME_DIR/work" ]] && mkdir "$OLDTIME_DIR/work" [[ ! -d "$OLDTIME_DIR/work/tmp" ]] && mkdir "$OLDTIME_DIR/work/tmp"