From: Frank Brehm Date: Tue, 8 Jun 2021 08:08:48 +0000 (+0200) Subject: Checking for directories X-Git-Tag: 2.2.6^2^2~6 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=2811d66687b774bbd95c556a2c1fdf8390265044;p=pixelpark%2Fcreate-vmware-tpl.git Checking for directories --- diff --git a/bin/get-centos8-streams-boot b/bin/get-centos8-streams-boot index c395aa4..e5de2cc 100755 --- a/bin/get-centos8-streams-boot +++ b/bin/get-centos8-streams-boot @@ -8,7 +8,7 @@ DEBUG="n" QUIET='n' SIMULATE="n" -VERSION="0.2.2" +VERSION="0.3.0" BASE_NAME="$(basename ${0})" BASE_DIR="$(dirname ${0})" @@ -37,7 +37,7 @@ declare -a URLS=() ARCH="x86_64" HAS_MOUNTED="n" -MOUNTPOINT="/var/tmp/centos8-stream-${ARCH}" +MOUNTPOINT_ROOT="/var/tmp/centos8-stream-${ARCH}" IMAGE_ROOT="/var/www/cobbler/ks_mirror" IMAGE_DIR="${IMAGE_ROOT}/CentOS-8-Stream-${ARCH}" LAST_TSTAMP="0" @@ -171,6 +171,12 @@ get_options() { ;; -q|--quiet) QUIET="y" + RED="" + YELLOW="" + GREEN="" + BLUE="" + CYAN="" + NORMAL="" shift ;; --nocolor) @@ -303,6 +309,21 @@ purge() { } +#------------------------------------------------------------------------------ +MKDIR() { + + local cmd="mkdir $*" + if [[ "${VERBOSE}" == "y" ]] ; then + cmd="mkdir --verbose $*" + fi + if [[ "${SIMULATE}" == "y" ]] ; then + info "Executing: ${cmd}" + return + fi + debug "Executing: ${cmd}" + eval ${cmd} +} + #------------------------------------------------------------------------------ set_locale() { @@ -413,6 +434,35 @@ check_preferences() { } +#------------------------------------------------------------------------------ +check_dirs() { + + info "Checking directories ..." + + local dir= + local all_ok="y" + + for dir in "${IMAGE_ROOT}" ; do + debug "Checking '${CYAN}${dir}${NORMAL}' ..." + if [[ ! -d "${dir}" ]] ; then + error "Directory '${RED}${dir}${NORMAL}' not found." + all_ok="n" + fi + done + + if [[ "${all_ok}" != "y" ]] ; then + exit 5 + fi + + for dir in "${MOUNTPOINT_ROOT}" ; do + debug "Checking '${CYAN}${dir}${NORMAL}' ..." + if [[ ! -d "${dir}" ]] ; then + MKDIR -p "${dir}" + fi + done + +} + #------------------------------------------------------------------------------ create_urls() { @@ -515,6 +565,7 @@ main() { check_preferences LOGFILE="${LOG_ROOTDIR}/${LOG_BASENAME}" + check_dirs empty_line dline