* sync: verbose mode added..

This commit is contained in:
Alper Kanat 2008-11-06 00:36:00 +00:00
parent 99ac67a04a
commit e9330d5bc4

25
sync
View File

@ -9,6 +9,7 @@ PLANET_DIR="${HOME}/public_html/gezegen"
LOG_DIR="$PLANET_DIR/logs" LOG_DIR="$PLANET_DIR/logs"
LOG_FILE="planet-$(date +"%d.%m.%Y").log" LOG_FILE="planet-$(date +"%d.%m.%Y").log"
LOCK_FILE="planet-sync.lck" LOCK_FILE="planet-sync.lck"
VERBOSE=0
usage() { usage() {
cat << EOF cat << EOF
@ -18,6 +19,7 @@ Options:
-h, --help this help -h, --help this help
-p, --planetdir useful if the planet dir is somewhere else than the -p, --planetdir useful if the planet dir is somewhere else than the
default one default one
-v, --verbose print the log instead of writing it to the log file..
Usage: $(basename $0) [--help] [--planetdir /path/to/planet] Usage: $(basename $0) [--help] [--planetdir /path/to/planet]
EOF EOF
@ -46,6 +48,11 @@ while (( $# > 0 )); do
shift 2 shift 2
;; ;;
--verbose|-v)
VERBOSE=1
shift
;;
-*) -*)
usage usage
exit 1 exit 1
@ -74,11 +81,19 @@ if [[ -f "$PLANET_DIR/$LOCK_FILE" ]]; then
exit 1 exit 1
else else
touch "$PLANET_DIR/$LOCK_FILE" touch "$PLANET_DIR/$LOCK_FILE"
echo >> "$LOG_DIR/$LOG_FILE" 2>&1 if (( $VERBOSE == 0 )); then
echo "starting new sync ($(date +"%d.%m.%Y, %H:%M"))" >> "$LOG_DIR/$LOG_FILE" 2>&1 echo >> "$LOG_DIR/$LOG_FILE" 2>&1
echo "-----------------------------------------------------------" >> "$LOG_DIR/$LOG_FILE" 2>&1 echo "starting new sync ($(date +"%d.%m.%Y, %H:%M"))" >> "$LOG_DIR/$LOG_FILE" 2>&1
"$PLANET_DIR/planet.py" "$PLANET_DIR/gezegen/config.ini" >> "$LOG_DIR/$LOG_FILE" 2>&1 echo "-----------------------------------------------------------" >> "$LOG_DIR/$LOG_FILE" 2>&1
echo "-----------------------------------------------------------" >> "$LOG_DIR/$LOG_FILE" 2>&1 "$PLANET_DIR/planet.py" "$PLANET_DIR/gezegen/config.ini" >> "$LOG_DIR/$LOG_FILE" 2>&1
echo "-----------------------------------------------------------" >> "$LOG_DIR/$LOG_FILE" 2>&1
else
echo
echo "starting new sync ($(date +"%d.%m.%Y, %H:%M"))"
echo "-----------------------------------------------------------"
"$PLANET_DIR/planet.py" "$PLANET_DIR/gezegen/config.ini"
echo "-----------------------------------------------------------"
fi
fi fi
# if ended successfully delete the lock file # if ended successfully delete the lock file