diff options
Diffstat (limited to 'old')
-rwxr-xr-x | old/MigrateFromGitwebUnixPermToGitolite.sh | 42 | ||||
-rwxr-xr-x | old/NewCGitUnixPermGitProject.sh | 85 | ||||
-rwxr-xr-x | old/UploadContentsToAnyclipServer.sh | 5 | ||||
-rwxr-xr-x | old/UploadNewGitGitwebUnixPerm.sh | 17 |
4 files changed, 149 insertions, 0 deletions
diff --git a/old/MigrateFromGitwebUnixPermToGitolite.sh b/old/MigrateFromGitwebUnixPermToGitolite.sh new file mode 100755 index 0000000..28f420d --- /dev/null +++ b/old/MigrateFromGitwebUnixPermToGitolite.sh @@ -0,0 +1,42 @@ +find . -type d -name .git | while read gitdir; do +pushd "$gitdir/../" > /dev/null + +name=`dirname "$gitdir"|cut -d / -f 2|cut -d ' ' -f 1` + +echo == Entering $name == + +url=$(grep 'url = zx2c4.com:git.zx2c4.com' .git/config | cut -d '=' -f 2 | tr -d ' ') +url=$(echo $url | cut -d ' ' -f 1) + +if ! echo $url | grep zx2c4.com > /dev/null; then + echo "Not a valid zx2c4 ssh repo." + echo + popd > /dev/null + continue +fi + +echo $url +scp $url/description .tmpdesc > /dev/null +description=$(cat .tmpdesc) +rm .tmpdesc +echo $description + +sed -i -e "s/url = zx2c4.*$/url = gitcode@zx2c4.com:$name/g" .git/config + +pushd ~/Projects/gitolite-admin/conf > /dev/null +echo "Writing config.." +(echo +echo " repo $name" +echo " RW+CD = zx2c4" +echo " R = @all" +echo " $name \"Jason A. Donenfeld\" = \"$description\"") >> gitolite.conf +git commit -a -m "Adding $name to repository." +git push +popd > /dev/null + +git push --all +git push --tags + +echo +popd > /dev/null +done
\ No newline at end of file diff --git a/old/NewCGitUnixPermGitProject.sh b/old/NewCGitUnixPermGitProject.sh new file mode 100755 index 0000000..856c884 --- /dev/null +++ b/old/NewCGitUnixPermGitProject.sh @@ -0,0 +1,85 @@ +#!/bin/sh + +##### Configure These Vars: ##### + +USER="git" +HOST="labs.anyclip.com" +REPOS="/home/$USER" +POSTCMD="$REPOS/updatewebinterface.sh" + +################################# + + +# Check environment +if [ "$1" == "" ]; then + echo "The first argument of this script must be the description of the git repository." + exit 1 +fi +if [ ! -d ".git" ]; then + echo "The current directory is not a git repository." + exit 1 +fi + +# Initialize constants +repository="`pwd | xargs -0 basename | tr -d ' '`" +connection="$USER@$HOST" +hash="`echo $REPOS $repository $connection $(date +%s%N) | md5sum | cut -d ' ' -f 1`" +options="-o ControlMaster=auto -o ControlPath=./.sshcontrolmaster-$hash" +gitsshpath="./.gitssh-$hash" + +# Create git ssh stub to use our options +echo -n "[*] Creating git ssh wrapper script..." +(echo '#!/bin/sh' > $gitsshpath && +echo -n 'exec ssh ' >> $gitsshpath && +echo -n "$options " >> $gitsshpath && +echo '"$@"' >> $gitsshpath && +chmod +x $gitsshpath) || { echo "failure!"; exit 1; } +echo "success." +export GIT_SSH="$gitsshpath" + +# Setup control master +echo -n "[*] Connecting to server..." +ssh $options -fN $connection || { echo "failure!"; exit 1; } +echo "success." + +# Create bare repo on server +echo -n "[*] Creating bare remote repository..." +ssh $options $connection "\ + cd \"$REPOS\" && \ + mkdir \"$repository\" &&\ + cd \"$repository\" &&\ + git init --bare &&\ + echo \"$1\" > description &&\ + mv hooks/post-update.sample hooks/post-update &&\ + chmod +x hooks/post-update;" > /dev/null 2>&1 || { echo "failure!"; exit 1; } +echo "success." + +# Add configuration for remote repo to local repo +echo -n "[*] Setting up local configuration..." +echo "[remote \"origin\"] + url = $connection:$REPOS/$repository + fetch = +refs/heads/*:refs/remotes/origin/* +[branch \"master\"] + remote = origin + merge = refs/heads/master" >> .git/config || { echo "failure!"; exit 1; } +echo "success." + +# Push local repo to remote repo +echo -n "[*] Uploading repository..." +git push --all > /dev/null 2>&1 || { echo "failure!"; exit 1; } +echo "success." + +# Run the post command if there is one +if [ "$POSTCMD" != "" ]; then + echo -n "[*] Running post-command..." + ssh $options $connection "$POSTCMD" || { echo "failure!"; exit 1; } + echo "success." +fi + +# Kill the ssh control master, delete gitssh wrapper +echo -n "[*] Cleaning up..." +ssh $options -O exit $connection 2> /dev/null || echo "\n\tClean up failed: could not kill ssh control master." +rm $gitsshpath > /dev/null || echo "\n\tClean up failed: could not delete git ssh wrapper." +echo "success." + +echo "Complete!" diff --git a/old/UploadContentsToAnyclipServer.sh b/old/UploadContentsToAnyclipServer.sh new file mode 100755 index 0000000..297a921 --- /dev/null +++ b/old/UploadContentsToAnyclipServer.sh @@ -0,0 +1,5 @@ +#!/bin/sh +shopt -s dotglob +directory=`pwd` +base=`basename "$directory"` +rsync -rlptDvz --exclude=*.pyc --exclude=.git --exclude=.gitignore --delete-excluded $1* labs.anyclip.com:/var/www/localhost/htdocs/$base/ diff --git a/old/UploadNewGitGitwebUnixPerm.sh b/old/UploadNewGitGitwebUnixPerm.sh new file mode 100755 index 0000000..b846a69 --- /dev/null +++ b/old/UploadNewGitGitwebUnixPerm.sh @@ -0,0 +1,17 @@ +currentDir=`pwd` +targetDir="`basename \"$currentDir\" | tr "[:upper:]" "[:lower:]"`.git" +ssh zx2c4.com "\ +cd ~/git.zx2c4.com;\ +mkdir \"$targetDir\";\ +cd \"$targetDir\"; +git init --bare;\ +echo \"$1\" > description;\ +mv hooks/post-update.sample hooks/post-update;\ +chmod +x hooks/post-update" +echo "[remote \"origin\"] + url = zx2c4.com:git.zx2c4.com/$targetDir + fetch = +refs/heads/*:refs/remotes/origin/* +[branch \"master\"] + remote = origin + merge = refs/heads/master" >> .git/config +git push --all |