]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Checking for directories
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 8 Jun 2021 08:08:48 +0000 (10:08 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 8 Jun 2021 08:08:48 +0000 (10:08 +0200)
bin/get-centos8-streams-boot

index c395aa4bbf47ec62e133b0326d669d27b382086b..e5de2ccf9a6ff1a102c68fac7092b384eee8ff32 100755 (executable)
@@ -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