From c47172c3f14bdd3c7eba3c10dae46fe04a9caf20 Mon Sep 17 00:00:00 2001 From: Joerg Jaspert Date: Sun, 28 Sep 2008 11:51:58 +0200 Subject: Various - use proper "" where we need them. - dont check if variables are defined that get defaults from us anyway. Signed-off-by: Joerg Jaspert --- bin/ftpsync | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'bin') diff --git a/bin/ftpsync b/bin/ftpsync index 68c640d..b44a87a 100755 --- a/bin/ftpsync +++ b/bin/ftpsync @@ -26,7 +26,7 @@ set -e NAME="`basename $0`" # In case we are called with an argument we look for a different configuration. -if [ -n $1 ]; +if [ -n "$1" ]; then NAME="${NAME}-$1" fi . ${HOME}/etc/${NAME}.conf @@ -97,11 +97,6 @@ EXCLUDE=${EXCLUDE:-""} # world-readable remotely. Always exclude it to avoid errors. EXCLUDE="${EXCLUDE} --exclude .~tmp~/" -# Check for some environment variables -if [ -z "${TO}" ] || [ -z "${RSYNC_HOST}" ] || [ -z "${RSYNC_PATH}" ]; then - error "One of the TO, RSYNC_HOST or RSYNC_PATH variables seems to be empty" - exit 2 -fi SOURCE_EXCLUDE= # Exclude architectures defined in $ARCH_EXCLUDE @@ -134,7 +129,7 @@ umask 002 # Otherwise we can end up with a half-synced archive: # - get a push # - sync, while locked -# - get another push. Of course no extra sync run then happens. +# - get another push. Of course no extra sync run then happens, we are locked. # - done. Archive not correctly synced, we don't have all the changes from the second push. touch "${UPDATEREQUIRED}" @@ -152,18 +147,17 @@ trap 'rm -f ${LOCK}; log "Mirrorsync done"; ${SAVELOG} "$LOG" > /dev/null' EXIT # Start log by redirecting everything there. exec >"$LOG" 2>&1 log "Mirrorsync start" - log "Acquired main lock" -if [ -n ${HOOK1} ]; then +export RSYNC_PASSWORD + +if [ -n "${HOOK1}" ]; then log "Running hook1: ${HOOK1}" ${HOOK1} result=$? log "Back from hook1, got returncode ${result}" fi -export RSYNC_PASSWORD - # Now do the actual mirroring, and run as long as we have an updaterequired file. while [ -e "${UPDATEREQUIRED}" ]; do log "Running mirrorsync, update is required, ${UPDATEREQUIRED} exists" @@ -178,7 +172,7 @@ while [ -e "${UPDATEREQUIRED}" ]; do # and us re-running. If it's not, uplink is broken anyways. if [ $result -eq 0 ] || [ $result -eq 24 ]; then - if [ -n ${HOOK2} ]; then + if [ -n "${HOOK2}" ]; then log "Running hook2: ${HOOK1}" ${HOOK2} result=$? @@ -191,7 +185,7 @@ while [ -e "${UPDATEREQUIRED}" ]; do ${RSYNC_USER}@${RSYNC_HOST}::${RSYNC_PATH} ${TO} result=$? if [ $result -eq 0 ] || [ $result -eq 24 ]; then - if [ -n ${HOOK3} ]; then + if [ -n "${HOOK3}" ]; then log "Running hook3: ${HOOK1}" ${HOOK3} result=$? @@ -211,7 +205,7 @@ if [ -d "${TO}/project/trace" ]; then date -u > "${TO}/project/trace/${HOSTNAME}" fi -if [ -n ${HOOK4} ]; then +if [ -n "${HOOK4}" ]; then log "Running hook4: ${HOOK1}" ${HOOK4} result=$? @@ -223,7 +217,7 @@ if [ x${HUB} = "xtrue" ]; then ${HOME}/bin/runmirrors log "Trigger slave done" - if [ -n ${HOOK5} ]; then + if [ -n "${HOOK5}" ]; then log "Running hook5: ${HOOK1}" ${HOOK5} result=$? -- cgit v1.2.3