aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilo Casagrande <milo@ubuntu.com>2013-03-12 17:06:43 +0100
committerMilo Casagrande <milo@ubuntu.com>2013-03-12 17:06:43 +0100
commitb6e5c4928c32e77b7965661dadd02c416353869c (patch)
tree94ab7d0620dfedef1bee8cf567f3433ed2975295
parent6ca011434dbb737d3d930c48566241558359becc (diff)
Refactored shell script.
-rw-r--r--scripts/rsync-mirror47
1 files changed, 36 insertions, 11 deletions
diff --git a/scripts/rsync-mirror b/scripts/rsync-mirror
index 3c47baa..6f44557 100644
--- a/scripts/rsync-mirror
+++ b/scripts/rsync-mirror
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
-# Script to ssh-rsync repositories between machines.
+# Script to ssh-rsync repositories between machines.
RHODECODE_USER=rhodecode
SSH_USER=git-linaro-staging
@@ -29,6 +29,29 @@ PRIVATE_PATH=$LOCAL_REPO_PATH/private
LINARO_PRIVATE_PATH=$PRIVATE_PATH/linaro-private
LANDING_TEAMS_PATH=$PRIVATE_PATH/landing-teams
+# TODO: when we have groups and user set up correctly both on the staging
+# and production instance, we need to change the rsync command in oder to
+# preserve also users, groups and access levels. With that, the function
+# can be removed and not used anymore.
+
+function set_own_perm {
+ # At the moment defaults everything to the rhodecode user and group.
+ # Might change in the future.
+ echo "Setting directories ownership..."
+ chown -R $RHODECODE_USER:$RHODECODE_USER $LOCAL_REPO_PATH
+
+ # chmod-correctly directories and files.
+ echo "Setting files and directories permissions..."
+ find $LOCAL_REPO_PATH -type d -exec chmod 775 {} \;
+ find $LOCAL_REPO_PATH -type f -exec chmod 664 {} \;
+}
+
+# Always set the permission/ownership.
+trap set_own_perm EXIT
+
+# Create the necessaries directories to hold private repositories.
+# We store everything under a single 'private' directory as a subdir
+# of RhodeCode git repositories one.
if [ ! -d $LINARO_PRIVATE_PATH ]
then
echo "Creating linaro-private directory..."
@@ -42,18 +65,20 @@ fi
# Sync private repositories, following symlinks and deleting locally.
echo "Rsyncing linaro-private repositories..."
-rsync -e "ssh -i $SSH_KEY -l $SSH_USER" -r -l --copy-unsafe-links -z -t --compress-level=8 --delete $SSH_USER@$GIT_SERVER:$LINARO_PRIVATE_REMOTE $LINARO_PRIVATE_PATH
+rsync -e "ssh -i $SSH_KEY -l $SSH_USER" -r -l --copy-unsafe-links -z -t \
+ --compress-level=8 --delete \
+ $SSH_USER@$GIT_SERVER:$LINARO_PRIVATE_REMOTE $LINARO_PRIVATE_PATH
+
echo "Rsyncing landing-teams private repositories..."
-rsync -e "ssh -i $SSH_KEY -l $SSH_USER" -r -l --copy-unsafe-links -z -t --compress-level=8 --delete $SSH_USER@$GIT_SERVER:$LANDING_TEAMS_REMOTE $LANDING_TEAMS_PATH
+rsync -e "ssh -i $SSH_KEY -l $SSH_USER" -r -l --copy-unsafe-links -z -t \
+ --compress-level=8 --delete \
+ $SSH_USER@$GIT_SERVER:$LANDING_TEAMS_REMOTE $LANDING_TEAMS_PATH
# Sync normal repositories, following symlinks and deleting locally.
+# Filter on the 'private' directory, otherwise it will be deleted since
+# we copy everything in the top directories of RhodeCode git.
echo "Rsyncing public repositories..."
-rsync -e "ssh -i $SSH_KEY -l $SSH_USER" -r -l --copy-unsafe-links -z -t --compress-level=8 --delete --filter=-r_/private/ $SSH_USER@$GIT_SERVER:$PUBLIC_REPO_PATH $LOCAL_REPO_PATH
-
-echo "Setting directories ownership..."
-chown -R $RHODECODE_USER:$RHODECODE_USER $LOCAL_REPO_PATH
-
-# chmod-correctly directories and files
-find $LOCAL_REPO_PATH -type d -exec chmod 775 {} \;
-find $LOCAL_REPO_PATH -type f -exec chmod 664 {} \;
+rsync -e "ssh -i $SSH_KEY -l $SSH_USER" -r -l --copy-unsafe-links -z -t \
+ --compress-level=8 --delete --filter=-r_/private/ \
+ $SSH_USER@$GIT_SERVER:$PUBLIC_REPO_PATH $LOCAL_REPO_PATH