Skip to content
Snippets Groups Projects
Commit b3926f2a authored by Ben Morrice's avatar Ben Morrice
Browse files

refactor script

- rename to c8refreshrepo
- source variables from config.sh
- disallow updates to 'production' SIGs
parent 17576f92
No related branches found
No related tags found
1 merge request!11[LOS-455] add script to faciliate manual 'refreshes' of individual repos within a snapshot
#!/bin/bash
BIN="/mnt/data2/home/build/bin"
source $BIN/config.sh
BASE=/mnt/data1/dist
RSYNC=/usr/bin/rsync
RSYNC_OPTS="-a --info=NAME"
YELLOW="\033[33m"
RED="\033[31m"
GREEN="\033[32m"
CYAN="\033[36m"
NORMAL="\033[39m"
TESTING=1
if [ $TESTING -eq 1 ]; then
......@@ -17,7 +15,7 @@ else
fi
if [ $EUID -ne 0 ]; then
echo -e $RED "As snapshot files are owned by root, this script should also be ran as root"
echo -e $ROUGE "As snapshot files are owned by root, this script should also be ran as root"
exit
fi
......@@ -30,6 +28,8 @@ This may be useful in the event when we do not want to execute a full 'testing'
Promoting a 'hotfix' into the 'CERN' repo
Manually refreshing upstream content into a SIG (such as 'cloud')
Refreshing SIGs is limited against the 'testing' snapshot to avoid potential problems arising from new SIG packages relying on dependencies that may not exist yet in 'production'.
OPTIONS:
-l Symlink to target, testing or production
......@@ -49,7 +49,7 @@ do
l)
SYMLINK=$OPTARG
if [ "$SYMLINK" != "testing" ] && [ "$SYMLINK" != "production" ]; then
echo -e $RED "Error: symlink should be 'testing' or 'production'"
echo -e $ROUGE "Error: symlink should be 'testing' or 'production'"
exit
fi
if [ "$SYMLINK" == "testing" ]; then
......@@ -76,12 +76,15 @@ if [ "$REPO" == "cern" ]; then
BASE_SOURCE=$BASE/internal/repos/cern8-stable
SUBDIRS="aarch64/os x86_64/os source/SRPMS"
else
if [ "$SYMLINK" != "testing" ]; then
echo -e $ROUGE "Error: refusing to work on a production SIG, this could cause unforseen broken dependencies"
exit
if [ -z $SIG ]; then
echo -e $RED "Error: SIG needed for sig content"
echo -e $ROUGE "Error: SIG needed for sig content"
exit
fi
if [ ! -d /mnt/data1/dist/centos/8/$SIG/x86_64/$REPO ]; then
echo -e $RED "Error: $REPO is not part of sig $SIG"
echo -e $ROUGE "Error: $REPO is not part of sig $SIG"
exit
else
BASE_SOURCE=/mnt/data1/dist/centos/8/$SIG
......@@ -104,22 +107,22 @@ for DIRECTORY in $SUBDIRS; do
TARGET=$SNAPSHOT/$SIG/$DIRECTORY/$REPO
SOURCE=$BASE_SOURCE/$DIRECTORY/$REPO
fi
echo -e $YELLOW "** Checking for new content in $SOURCE"
echo -e $JAUNE "** Checking for new content in $SOURCE"
# -n is dryrun
RSYNC_OUTPUT=`$RSYNC -n $RSYNC_OPTS $SOURCE/ $TARGET`
if [ "$RSYNC_OUTPUT" == "" ]; then
echo -e $GREEN "No difference to files in $SOURCE compared to $TARGET"
echo -e $VERT "No difference to files in $SOURCE compared to $TARGET"
else
echo -e $NORMAL "$RSYNC_OUTPUT"
echo -n -e $NORMAL "Should the above content be synced to $TARGET ? (y/n): "
read CONFIRM_RSYNC
if [ $CONFIRM_RSYNC == "y" ] || [ $CONFIRM_RSYNC == "Y" ]; then
echo -e $GREEN "Copying from $SOURCE to $TARGET"
echo -e $VERT "Copying from $SOURCE to $TARGET"
echo -e $NORMAL
$RSYNC $RSYNC_OPTS $SOURCE/ $TARGET
echo -e $GREEN "Content synced from $SOURCE to $TARGET"
echo -e $VERT "Content synced from $SOURCE to $TARGET"
else
echo -e $RED "Not running rsync as per user request"
echo -e $ROUGE "Not running rsync as per user request"
fi
fi
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment