From ac523bec0f42b13db22a27352690f2fd23f8fe3b Mon Sep 17 00:00:00 2001
From: Jan Vales <jan@jvales.net>
Date: Thu, 26 Nov 2015 01:59:19 +0100
Subject: [PATCH] Added script to gitify all directories (and later manually
 rsync them into public share)

---
 git_all_services.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100755 git_all_services.sh

diff --git a/git_all_services.sh b/git_all_services.sh
new file mode 100755
index 0000000..39ed7b9
--- /dev/null
+++ b/git_all_services.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+#
+# Copyright 2015 by Jan Vales <jan@jvales.net> (Someone <someone@somenet.org>)
+# send me your changes. credit author(s). do not publish. share alike.
+# to be done: find a suitable licence text.
+#
+# Script to add all directories in ./ to separate git repositories and push them somewhere safe.
+# Use on vmVULN
+
+echo "GIT ALL T3H SERVICES!"
+CURRENTPWD=$(pwd)
+
+if [[ $1 == "" ]] ; then
+	echo "ERROR: No commit message given! Aborting."
+	exit 1
+fi
+
+umask 077
+
+for dir in ./* ; do
+	if [[ -d "${CURRENTPWD}/${dir}" ]] ; then
+		cd "${CURRENTPWD}/${dir}"
+		echo "Doing git dir: $dir"
+
+		if [[ ! -d ".git" ]] ; then
+			echo "*** WARN: git repo not found. creating..."
+			git init
+			git config user.name git_all_script
+			git config user.email lol@example.com
+			git config rebase.stat true
+
+			git commit --allow-empty -m "Initial commit"
+			git tag InitialCommit
+		fi
+
+		touch setPerms.autogenerated.sh
+
+		chown -R root:root "${CURRENTPWD}/${dir}/.git" "setPerms.autogenerated.sh"
+		chmod -R 600 "${CURRENTPWD}/${dir}/.git" "setPerms.autogenerated.sh"
+
+		find . -not -type l -not -path './.git/*' -exec stat {} -c "chmod %a \"%n\"; chown %u:%g \"%n\"" \; | sort -k 3 > setPerms.autogenerated.sh
+
+		chmod -R +x setPerms.autogenerated.sh
+
+		git config user.name git_all_script
+		git config user.email script@w0y.invalid
+		git config rebase.stat true
+#		git config remote.origin.url="ssh://git@s.i:2/media/sf_vmshare/git/${dir}"
+#		git config remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
+#		git config branch.master.remote=origin
+#		git config branch.master.merge=refs/heads/master
+		git config branch.master.rebase true
+
+		git add -f .
+		git commit -a -m "$1"
+	fi
+done
+
+cd "${CURRENTPWD}"
+echo "DONE. now rsync this directory away (pull from remote) NOW!"
+
-- 
2.43.0