-
Notifications
You must be signed in to change notification settings - Fork 21
(INF-3292) Move xdmod rsync cron image #304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
williamnswanson
wants to merge
4
commits into
opensciencegrid:main
Choose a base branch
from
williamnswanson:INF-3292.xdmod-rsync-cron-image
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1fd6e20
Copy xdmod-ospool-fetch from https://github.com/jasoncpatton/xdmod-os…
williamnswanson 4568aad
Add --delete flag to generated cron's rsync command
williamnswanson ac97b30
xdmod-ospool-fetch: Create build-config.json
williamnswanson d68ee5c
xdmod-ospool-fetch: use ARGs for determining FROM image in Dockerfile
williamnswanson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2024 Jason Patton | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I give permission to change the ©️ here or remove the |
||
|
|
||
| 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. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"] | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
rsyncmanpage (emphasis added):