Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions opensciencegrid/xdmod-ospool-fetch/19_rsync_setup.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF
SHELL=/bin/bash
PATH=/usr/sbin:/usr/bin:/sbin:/bin
RSYNC_KEYS_CONFIG_DIR=${RSYNC_KEYS_CONFIG_DIR}
*/5 ${RSYNC_CRON_HOUR:-8} * * * root /etc/osg/image-config.d/19_rsync_setup.sh 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 <<EOF
SHELL=/bin/bash
PATH=/usr/sbin:/usr/bin:/sbin:/bin
${RSYNC_CRON_MINUTE:-30} ${RSYNC_CRON_HOUR:-8} * * * root rsync -ave --delete ssh ${RSYNC_SOURCE} ${RSYNC_TARGET} >>/var/log/rsync-ospool-logs.log 2>&1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems correct to me, per the rsync man page (emphasis added):

--delete delete extraneous files from **dest** dirs

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
11 changes: 11 additions & 0 deletions opensciencegrid/xdmod-ospool-fetch/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions opensciencegrid/xdmod-ospool-fetch/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Jason Patton
Copy link
Copy Markdown
Contributor

@jasoncpatton jasoncpatton Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I give permission to change the ©️ here or remove the LICENSE entirely since it's going into a organization-owned repo.


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.
7 changes: 7 additions & 0 deletions opensciencegrid/xdmod-ospool-fetch/build-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"standard_build": true,
"repo_build": false,
"base_os": ["el9"],
"osg_series": ["25"],
"base_repo": ["release"]
}
Loading