]> git.somenet.org - ctf/pub/adminscripts.git/blob - git_all_services.sh
GITOLITE.txt
[ctf/pub/adminscripts.git] / git_all_services.sh
1 #!/bin/bash
2 #
3 # Copyright 2015 by Jan Vales <jan@jvales.net> (Someone <someone@somenet.org>)
4 # send me your changes. credit author(s). do not publish. share alike.
5 # to be done: find a suitable licence text.
6 #
7 # Script to add all directories in ./ to separate git repositories and push them somewhere safe.
8 # Use on vmVULN
9
10 echo "GIT ALL T3H SERVICES!"
11 CURRENTPWD=$(pwd)
12
13 if [[ $1 == "" ]] ; then
14         echo "ERROR: No commit message given! Aborting."
15         exit 1
16 fi
17
18 umask 077
19
20 for dir in ./* ; do
21         if [[ -d "${CURRENTPWD}/${dir}" ]] ; then
22                 cd "${CURRENTPWD}/${dir}"
23                 echo "Doing git dir: $dir"
24
25                 if [[ ! -d ".git" ]] ; then
26                         echo "*** WARN: git repo not found. creating..."
27                         git init
28                         git config user.name git_all_script
29                         git config user.email lol@example.com
30                         git config rebase.stat true
31
32                         git commit --allow-empty -m "Initial commit"
33                         git tag InitialCommit
34                 fi
35
36                 touch setPerms.autogenerated.sh
37
38                 chown -R root:root "${CURRENTPWD}/${dir}/.git" "setPerms.autogenerated.sh"
39                 chmod -R 600 "${CURRENTPWD}/${dir}/.git" "setPerms.autogenerated.sh"
40
41                 find . -not -type l -not -path './.git/*' -exec stat {} -c "chmod %a \"%n\"; chown %u:%g \"%n\"" \; | sort -k 3 > setPerms.autogenerated.sh
42
43                 chmod -R +x setPerms.autogenerated.sh
44
45                 git config user.name git_all_script
46                 git config user.email script@w0y.invalid
47                 git config rebase.stat true
48 #               git config remote.origin.url="ssh://git@s.i:2/media/sf_vmshare/git/${dir}"
49 #               git config remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
50 #               git config branch.master.remote=origin
51 #               git config branch.master.merge=refs/heads/master
52                 git config branch.master.rebase true
53
54                 git add -f .
55                 git commit -a -m "$1"
56         fi
57 done
58
59 cd "${CURRENTPWD}"
60 echo "DONE. now rsync this directory away (pull from remote) NOW!"
61