CYAN=""
NORMAL=""
-VERSION="0.2.1"
+VERSION="0.2.2"
# shellcheck disable=SC2034
STD_SHORT_OPTIONS="sqdvhV"
if [[ "${VERBOSE}" != "y" ]] ; then
return 0
fi
+ if [[ -n "${LOGFILE}" ]] ; then
+ echo -e "[$(my_date)] [${BASE_NAME}:${CYAN}DEBUG${NORMAL}]: $@" >>"${LOGFILE}"
+ fi
echo -e " * [$(my_date)] [${BASE_NAME}:${CYAN}DEBUG${NORMAL}]: $*" >&2
}
#------------------------------------------------------------------------------
info() {
+ if [[ -n "${LOGFILE}" ]] ; then
+ echo -e "[$(my_date)] [${BASE_NAME}:${GREEN}DEBUG${NORMAL}]: $@" >>"${LOGFILE}"
+ fi
if [[ "${QUIET}" != "y" ]] ; then
echo -e " ${GREEN}*${NORMAL} [$(my_date)] [${BASE_NAME}:${GREEN}INFO${NORMAL}] : $*" >&2
fi
#------------------------------------------------------------------------------
warn() {
+ if [[ -n "${LOGFILE}" ]] ; then
+ echo -e "[$(my_date)] [${BASE_NAME}:${YELLOW}DEBUG${NORMAL}]: $@" >>"${LOGFILE}"
+ fi
echo -e " ${YELLOW}*${NORMAL} [$(my_date)] [${BASE_NAME}:${YELLOW}WARN${NORMAL}] : $*" >&2
}
#------------------------------------------------------------------------------
error() {
+ if [[ -n "${LOGFILE}" ]] ; then
+ echo -e "[$(my_date)] [${BASE_NAME}:${RED}DEBUG${NORMAL}]: $@" >>"${LOGFILE}"
+ fi
echo -e " ${RED}*${NORMAL} [$(my_date)] [${BASE_NAME}:${RED}ERROR${NORMAL}]: $*" >&2
}
eval ${cmd}
}
+#------------------------------------------------------------------------------
+MKDIR_forced() {
+
+ local cmd="mkdir $*"
+ if [[ "${VERBOSE}" == "y" ]] ; then
+ cmd="mkdir --verbose $*"
+ fi
+ debug "Executing: ${cmd}"
+ eval ${cmd}
+}
+
#------------------------------------------------------------------------------
CHOWN() {
empty_line() {
if [[ -n "${LOGFILE}" ]] ; then
- echo >>"${LOGFILE}"
+ echo >> "${LOGFILE}"
fi
if [[ "${QUIET}" == "y" ]] ; then
detect_color
IMAGE_ROOT="/var/www/cobbler/distro_mirror"
+LOG_DIR="/var/log/update-cobbler-distros"
DIR_OWNER="apache"
DIR_GROUP="apache"
-declare -a DISTRO_IDS=( 'almalinux-8' 'centos-stream-8' 'centos-stream-9' )
+declare -a DISTRO_IDS=( 'almalinux-8' 'almalinux-9' 'centos-stream-8' 'centos-stream-9' 'rocky-8' )
declare -a DISTRO_ID_UPDATE=()
declare -A SOURCE=()
SOURCE['almalinux-8']="rsync://ftp.fau.de/almalinux/8/BaseOS/x86_64/os/"
TARGET['almalinux-8']="AlmaLinux-8"
+SOURCE['almalinux-9']="rsync://ftp.fau.de/almalinux/9/BaseOS/x86_64/os/"
+TARGET['almalinux-9']="AlmaLinux-9"
+
SOURCE['centos-stream-8']="rsync://ftp.fau.de/centos/8-stream/BaseOS/x86_64/os/"
TARGET['centos-stream-8']="CentOS-Stream-8"
SOURCE['centos-stream-9']="rsync://mirror1.hs-esslingen.de/centos-stream/9-stream/BaseOS/x86_64/os/"
TARGET['centos-stream-9']="CentOS-Stream-9"
+SOURCE['rocky-8']="rsync://ftp.fau.de/rockylinux/8/BaseOS/x86_64/os/"
+TARGET['rocky-8']="Rocky-8"
+
DESCRIPTION=$( cat <<-EOF
Updates the boot environments of cobbler boot environments.
}
+#------------------------------------------------------------------------------
+check_preferences() {
+
+ info "Checking preferences ..."
+ local all_ok="y"
+
+ check_for_root
+
+ local -a tools=('rsync')
+ local tool=
+
+ for tool in "${tools[@]}" ; do
+ debug "Checking for '${CYAN}${tool}${NORMAL}' ..."
+ if type -p ${tool} >/dev/null ; then
+ :
+ else
+ all_ok="n"
+ error "Did not found '${RED}${tool}${NORMAL}'. Maybe not installed?"
+ fi
+ done
+
+ if [[ "${all_ok}" != "y" ]] ; then
+ exit 5
+ fi
+
+ if [[ ! -d "${LOG_DIR}" ]] ; then
+ info "Creating '${GREEN}${LOG_DIR}${NORMAL}' ..."
+ MKDIR_forced "${LOG_DIR}"
+ fi
+
+}
+
#------------------------------------------------------------------------------
update_distro() {
# info "Chowning '${CYAN}${target_dir}${NORMAL}' to '${CYAN}${DIR_OWNER}:${DIR_GROUP}${CYAN}' ..."
# CHOWN --recursive "${DIR_OWNER}:${DIR_GROUP}" "${target_dir}"
+ info "Finished '${CYAN}${src_url}${NORMAL}'."
return 0
get_options "$@"
+ check_preferences
+
for distro_id in "${DISTRO_ID_UPDATE[@]}" ; do
+ LOGFILE="${LOG_DIR}/${distro_id}.log"
empty_line
line
info "Updating Cobbler distribution '${GREEN}${distro_id}${NORMAL}' ..."
update_distro "${distro_id}"
done
+ LOGFILE=
+ empty_line
+ info "Finished all."
+
}
main "$@"