From: Frank Brehm Date: Sat, 18 Nov 2017 15:34:29 +0000 (+0100) Subject: Creating main loop X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=bd4866501dcd0e88271e53446242525621f172ef;p=my-stuff%2Ftools.git Creating main loop --- diff --git a/bin/convert-stack.sh b/bin/convert-stack.sh index bae2a12..53597ee 100755 --- a/bin/convert-stack.sh +++ b/bin/convert-stack.sh @@ -11,7 +11,7 @@ DEBUG="n" QUIET='n' SIMULATE="n" -VERSION="0.2" +VERSION="0.3" # console colors: RED="" @@ -247,9 +247,13 @@ get_options() { exit 5 fi - if [[ -n "${LINK_DIR}" && ! -d "${LINK_DIR}" ]] ; then - error "Given link directory '${RED}${LINK_DIR}${NORMAL}' does not exists." - exit 1 + if [[ -n "${LINK_DIR}" ]] ; then + if [[ ! -d "${LINK_DIR}" ]] ; then + error "Given link directory '${RED}${LINK_DIR}${NORMAL}' does not exists." + exit 1 + fi + LINK_DIR=$( readlink --canonicalize "${LINK_DIR}" ) + debug "Directory for hard links is: '${LINK_DIR}'." fi } @@ -312,18 +316,52 @@ LN() { ## ################################################################################ +#------------------------------------------------------------------------------ +perform_csv() { + + local lnr=0 + local oifs="${IFS}" + IFS=" +" + + local -a lines=() + local line= + + for line in $( cat "${CSV_FILE}" ); do + lines+=( $line ) + done + IFS="$oifs" + + for line in "${lines[@]}" ; do + + lnr=$(( $lnr + 1 )) + + if echo "${line}" | egrep -q '^[ ]*(#.*)?$' ; then + debug "Don't evaluate line ${lnr}: ${line}" + continue + fi + debug "Evaluating line ${lnr}: ${line}" + + done + +} + #------------------------------------------------------------------------------ main() { get_options "$@" + if [[ "${SIMULATE}" == "y" ]] ; then + info "Simulation mode, nothing will be really done." + echo + fi + + cd $( dirname "${CSV_FILE}" ) + debug "Current directory is now: '$( pwd )'." -# prepare_dirs -# info "Starting backup ..." -# cleanup_old_backups -# get_zones -# backup_zones + info "Starting stack converting ..." + perform_csv -# empty_line + echo info "Finished." }