]> Frank Brehm's Git Trees - scripts/root-bin.git/commitdiff
Adding deploy-incoming
authorFrank Brehm <frank@brehm-online.com>
Fri, 30 Dec 2022 09:53:40 +0000 (10:53 +0100)
committerFrank Brehm <frank@brehm-online.com>
Fri, 30 Dec 2022 09:53:40 +0000 (10:53 +0100)
deploy-incoming [new file with mode: 0755]

diff --git a/deploy-incoming b/deploy-incoming
new file mode 100755 (executable)
index 0000000..8568ad5
--- /dev/null
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+set -eu
+
+REPO_ROOT="/var/www/html"
+INCOMING_ROOT="/var/www/incoming"
+REPO_USER=repo
+REPO_GROUP=users
+
+declare -A MAPPINGS=()
+
+MAPPINGS['debian/deb10']='Debian/buster'
+MAPPINGS['debian/deb11']='Debian/bullseye'
+MAPPINGS['debian/deb12']='Debian/bookworm'
+MAPPINGS['debian/ubuntu18.04']='Ubuntu/bionic'
+MAPPINGS['debian/ubuntu20.04']='Ubuntu/focal'
+MAPPINGS['debian/ubuntu22.04']='Ubuntu/jammy'
+MAPPINGS['debian/src']='Sources'
+MAPPINGS['el/el-7']='Yum/el-7'
+MAPPINGS['el/el-8']='Yum/el-8'
+MAPPINGS['el/el-9']='Yum/el-9'
+MAPPINGS['el/el-10']='Yum/el-10'
+
+for src_dir_part in "${!MAPPINGS[@]}" ; do
+
+    src_dir="${INCOMING_ROOT}/${src_dir_part}"
+    tgt_dir="${REPO_ROOT}/${MAPPINGS[${src_dir_part}]}"
+    src_tgt_dir="${REPO_ROOT}/${MAPPINGS[${src_dir_part}]}-src"
+
+    if [[ -d "${src_dir}" ]] ; then
+        echo
+        echo "Moving ${src_dir}/* -> ${tgt_dir} ..."
+
+        for file in ${src_dir}/* ; do
+            if [[ -f "${file}" ]] ; then
+                # echo " * ${file}"
+                tgt="${tgt_dir}"
+                if [[ "${src_dir_part}" =~ ^el && "${file}" =~ src\.rpm$ ]] ; then
+                    tgt="${src_tgt_dir}"
+                fi
+                if [[ ! -d "${tgt}" ]] ; then
+                    printf " * "
+                    mkdir -p -v "${tgt}/"
+                fi
+                printf " * "
+                mv -v "${file}" "${tgt}/"
+            fi
+
+        done
+
+        echo
+        echo "Chowning '${src_dir}' to ${REPO_USER}:${REPO_GROUP} ..."
+        chown -R ${REPO_USER}:${REPO_GROUP} "${src_dir}"
+
+    fi
+done
+
+for repo_dir in "${REPO_ROOT}"/Yum/* ; do
+
+    bname=$( basename "${repo_dir}" )
+    if [[ -d "${repo_dir}" && "${bname}" =~ ^el- ]] ; then
+
+        echo
+        echo "Creating Yum repo in '${repo_dir}' ..."
+        if [[ -d "${repo_dir}/repodata" ]] ; then
+            createrepo_c --update "${repo_dir}"
+        else
+            createrepo_c "${repo_dir}"
+        fi
+
+        echo
+        echo "Chowning '${repo_dir}/repodata' to ${REPO_USER}:${REPO_GROUP} ..."
+        chown -R ${REPO_USER}:${REPO_GROUP} "${repo_dir}/repodata"
+
+    fi
+
+done
+
+
+# vim: ts=4 et sw=4