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/bash
BIN="/mnt/data2/home/build/bin"
source $BIN/config.sh
BASE=/mnt/data1/dist BASE=/mnt/data1/dist
RSYNC=/usr/bin/rsync RSYNC=/usr/bin/rsync
RSYNC_OPTS="-a --info=NAME" RSYNC_OPTS="-a --info=NAME"
YELLOW="\033[33m"
RED="\033[31m"
GREEN="\033[32m"
CYAN="\033[36m"
NORMAL="\033[39m"
TESTING=1 TESTING=1
if [ $TESTING -eq 1 ]; then if [ $TESTING -eq 1 ]; then
...@@ -17,7 +15,7 @@ else ...@@ -17,7 +15,7 @@ else
fi fi
if [ $EUID -ne 0 ]; then 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 exit
fi fi
...@@ -30,6 +28,8 @@ This may be useful in the event when we do not want to execute a full 'testing' ...@@ -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 Promoting a 'hotfix' into the 'CERN' repo
Manually refreshing upstream content into a SIG (such as 'cloud') 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: OPTIONS:
-l Symlink to target, testing or production -l Symlink to target, testing or production
...@@ -49,7 +49,7 @@ do ...@@ -49,7 +49,7 @@ do
l) l)
SYMLINK=$OPTARG SYMLINK=$OPTARG
if [ "$SYMLINK" != "testing" ] && [ "$SYMLINK" != "production" ]; then 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 exit
fi fi
if [ "$SYMLINK" == "testing" ]; then if [ "$SYMLINK" == "testing" ]; then
...@@ -76,12 +76,15 @@ if [ "$REPO" == "cern" ]; then ...@@ -76,12 +76,15 @@ if [ "$REPO" == "cern" ]; then
BASE_SOURCE=$BASE/internal/repos/cern8-stable BASE_SOURCE=$BASE/internal/repos/cern8-stable
SUBDIRS="aarch64/os x86_64/os source/SRPMS" SUBDIRS="aarch64/os x86_64/os source/SRPMS"
else 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 if [ -z $SIG ]; then
echo -e $RED "Error: SIG needed for sig content" echo -e $ROUGE "Error: SIG needed for sig content"
exit exit
fi fi
if [ ! -d /mnt/data1/dist/centos/8/$SIG/x86_64/$REPO ]; then 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 exit
else else
BASE_SOURCE=/mnt/data1/dist/centos/8/$SIG BASE_SOURCE=/mnt/data1/dist/centos/8/$SIG
...@@ -104,22 +107,22 @@ for DIRECTORY in $SUBDIRS; do ...@@ -104,22 +107,22 @@ for DIRECTORY in $SUBDIRS; do
TARGET=$SNAPSHOT/$SIG/$DIRECTORY/$REPO TARGET=$SNAPSHOT/$SIG/$DIRECTORY/$REPO
SOURCE=$BASE_SOURCE/$DIRECTORY/$REPO SOURCE=$BASE_SOURCE/$DIRECTORY/$REPO
fi fi
echo -e $YELLOW "** Checking for new content in $SOURCE" echo -e $JAUNE "** Checking for new content in $SOURCE"
# -n is dryrun # -n is dryrun
RSYNC_OUTPUT=`$RSYNC -n $RSYNC_OPTS $SOURCE/ $TARGET` RSYNC_OUTPUT=`$RSYNC -n $RSYNC_OPTS $SOURCE/ $TARGET`
if [ "$RSYNC_OUTPUT" == "" ]; then 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 else
echo -e $NORMAL "$RSYNC_OUTPUT" echo -e $NORMAL "$RSYNC_OUTPUT"
echo -n -e $NORMAL "Should the above content be synced to $TARGET ? (y/n): " echo -n -e $NORMAL "Should the above content be synced to $TARGET ? (y/n): "
read CONFIRM_RSYNC read CONFIRM_RSYNC
if [ $CONFIRM_RSYNC == "y" ] || [ $CONFIRM_RSYNC == "Y" ]; then 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 echo -e $NORMAL
$RSYNC $RSYNC_OPTS $SOURCE/ $TARGET $RSYNC $RSYNC_OPTS $SOURCE/ $TARGET
echo -e $GREEN "Content synced from $SOURCE to $TARGET" echo -e $VERT "Content synced from $SOURCE to $TARGET"
else else
echo -e $RED "Not running rsync as per user request" echo -e $ROUGE "Not running rsync as per user request"
fi fi
fi fi
done done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment