Batch git init and push for Serverpilot apps
#!/bin/bash | |
# Bash script to initialize, do first commit and push to git server | |
# Rudy Affandi (2016) | |
# Variables | |
gitignore=/srv/users/serverpilot/latest/.gitignore | |
counter=0 | |
clear | |
echo | |
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" | |
echo "#" | |
echo "# Initialize, commit and push to Git Server" | |
echo "#" | |
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" | |
echo | |
for dir in /srv/users/serverpilot/apps/* | |
do | |
# Check for sites without .git | |
if [ ! -d "$dir/public/.git" ]; then | |
echo "cd $dir/public" | |
cd $dir/public | |
echo "Initializing git..." | |
echo "git init" | |
echo | |
git init | |
echo "Add all tracked files/folders..." | |
echo "git add ." | |
echo | |
git add . | |
echo "Make initial commit..." | |
echo "git commit -m 'Initial commit :hatching_chick:'" | |
echo | |
git commit -m "Initial commit :hatching_chick:" | |
echo "Adding remote git URL..." | |
echo "git remote add <ORIGIN> <REPO>/$(basename $dir).git" | |
echo | |
git remote add <ORIGIN> <REPO>/$(basename $dir).git | |
echo "Register this repo to batchgit..." | |
echo "batchgit -a ./" | |
batchgit -a ./ | |
fi | |
((counter++)) | |
done | |
echo | |
echo "All apps have been added to git repository" | |
echo $counter in total |
#!/bin/bash | |
# Bash script to push commits to Git server | |
# Rudy Affandi (2016) | |
# Variables | |
counter=0 | |
clear | |
echo | |
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" | |
echo "#" | |
echo "# Push commits to Git server" | |
echo "#" | |
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" | |
echo | |
for dir in /srv/users/serverpilot/apps/* | |
do | |
# Check for v2 sites with .git | |
if [ -d "$dir/.git" ]; then | |
echo "cd $dir" | |
cd $dir | |
echo "Remove ignored files/folders..." | |
echo "git rm -r --cached ." | |
echo | |
git rm -r --cached . | |
echo "Commit changes..." | |
echo "git commit -m 'Remove ignored files and folders `date +%Y-%m-%H\ %k:%M:%S`'" | |
echo | |
git commit -m "Remove ignored files and folders `date +%Y-%m-%H\ %k:%M:%S`" | |
echo "Push..." | |
echo "git push -u <ORIGIN> <BRANCH>" | |
echo | |
git push -u <ORIGIN> <BRANCH> | |
fi | |
((counter++)) | |
done | |
echo | |
echo "All apps have been pushed to git repository" | |
echo $counter in total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Make sure to update to your git repo URL, to your branch name, and to your git remote name.