diff --git a/opensciencegrid/xdmod-ospool-fetch/19_rsync_setup.sh b/opensciencegrid/xdmod-ospool-fetch/19_rsync_setup.sh new file mode 100644 index 00000000..86529c74 --- /dev/null +++ b/opensciencegrid/xdmod-ospool-fetch/19_rsync_setup.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Fail if variables are unset +set -u + +RSYNC_KEYS_CONFIG_DIR=${RSYNC_KEYS_CONFIG_DIR:-/mnt/ssh-keys-config} + +mode="${1:-init}" +if [[ "$mode" != "cron" ]]; then + mkdir -p /root/.ssh + chmod 700 /root/.ssh +fi + +# Always (re)install the ssh key when this script runs +pushd $RSYNC_KEYS_CONFIG_DIR +for FILE in *; do + echo "Installing ssh key/config $FILE to /root/.ssh/$FILE" + install -o root -g root -m 0600 $FILE /root/.ssh/$FILE +done +popd + +if [[ "$mode" != "cron" ]]; then + # Periodically re-install the ssh key every 5 minutes around rsync time + cat >/etc/cron.d/rsync-setup.cron <>/var/log/rsync-setup.log 2>&1 +EOF + + # Run the rsync once per day, time in UTC + cat >/etc/cron.d/rsync-ospool-logs.cron <>/var/log/rsync-ospool-logs.log 2>&1 +EOF + + # Run the rsync now if RUN_RSYNC_NOW is defined + if [[ "x${RUN_RSYNC_NOW}" != "x" ]]; then + echo "Running rsync on startup from ${RSYNC_SOURCE} to ${RSYNC_TARGET}" + rsync -ave ssh ${RSYNC_SOURCE} ${RSYNC_TARGET} >>/var/log/rsync-ospool-logs.log 2>&1 + fi +fi diff --git a/opensciencegrid/xdmod-ospool-fetch/Dockerfile b/opensciencegrid/xdmod-ospool-fetch/Dockerfile new file mode 100644 index 00000000..6e0d5348 --- /dev/null +++ b/opensciencegrid/xdmod-ospool-fetch/Dockerfile @@ -0,0 +1,11 @@ +ARG BASE_OS=el9 +ARG BASE_OSG_SERIES=25 +ARG BASE_YUM_REPO=release + +FROM opensciencegrid/software-base:$BASE_OSG_SERIES-$BASE_OS-$BASE_YUM_REPO + +RUN yum install -y rsync openssh-clients && \ +yum clean all && \ +rm -rf /var/cache/yum/ + +COPY 19_rsync_setup.sh /etc/osg/image-config.d/19_rsync_setup.sh diff --git a/opensciencegrid/xdmod-ospool-fetch/LICENSE b/opensciencegrid/xdmod-ospool-fetch/LICENSE new file mode 100644 index 00000000..34a3b7e5 --- /dev/null +++ b/opensciencegrid/xdmod-ospool-fetch/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Jason Patton + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/opensciencegrid/xdmod-ospool-fetch/build-config.json b/opensciencegrid/xdmod-ospool-fetch/build-config.json new file mode 100644 index 00000000..a86125ff --- /dev/null +++ b/opensciencegrid/xdmod-ospool-fetch/build-config.json @@ -0,0 +1,7 @@ +{ + "standard_build": true, + "repo_build": false, + "base_os": ["el9"], + "osg_series": ["25"], + "base_repo": ["release"] + }