Last active
May 6, 2016 17:29
-
-
Save dmsimard/c17503abb0f9a69ea3a9a4d3225886db to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
# Adds the rdo-core group to a list of projects | |
GIT_BASE_URL="ssh://admin@review.rdoproject.org:29418" | |
BASE_DIR="/tmp/sfaccess" | |
PROJECT_FILE="/tmp/projects" | |
export GIT_COMMITTER_NAME="SF initial configurator" | |
export GIT_COMMITTER_EMAIL="admin@review.rdoproject.org" | |
export GIT_AUTHOR_NAME="SF initial configurator" | |
export GIT_AUTHOR_EMAIL="admin@review.rdoproject.org" | |
rm -rf $BASE_DIR | |
mkdir -p $BASE_DIR | |
cd $BASE_DIR | |
for project in $(cat $PROJECT_FILE) | |
do | |
repository="${GIT_BASE_URL}/${project}" | |
project_name=${project#*/} | |
project_core_group="$(sed "s,.*/,," <<< $project_name)-core" | |
git clone $repository --depth=1 | |
pushd "${BASE_DIR}/${project_name}" | |
git fetch origin refs/meta/config | |
git checkout FETCH_HEAD | |
awk '/Registered Users/{print "63673ea7f2ae6a5666566b1ea9f14e473d00f5a9\trdo-core"}1' groups > groups.tmp | |
mv groups.tmp groups | |
IFS='' | |
while read line | |
do | |
echo $line >> project.tmp | |
echo $line | grep -q "${project_core_group}" | |
if [ $? -eq 0 ]; then | |
echo $line |sed -e "s/group .*$project_core_group/group rdo-core/" >> project.tmp | |
fi | |
done < project.config | |
mv project.tmp project.config | |
git commit -am "[dmsimard] Add rdo-core group to project access" | |
git push origin HEAD:refs/meta/config | |
popd | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment