summaryrefslogtreecommitdiffstats
path: root/update_all_submodules
blob: d0bf837479574416f2729f6447c81b7ad74d9d05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash

if [[ -e /var/lock/update-tde-git-submodules ]]; then
        echo "TDE GIT submodules are currently being updated"
        echo "If this is not the case, please remove the lockfile /var/lock/update-tde-git-submodules"
        exit 0
fi

touch /var/lock/update-tde-git-submodules

PARENTDIR=$PWD
echo "Working in $PARENTDIR"
if [[ ! -d .git ]]; then
	echo "Current directory does not contain a .git folder.  Exiting..."
	exit 1
fi
git pull
git reset --hard HEAD
git clean -d -x -f

exec 3< submodules
while read <&3
do
	cd $PARENTDIR
	DIR2UPDATE=$REPLY
	if [[ $DIR2UPDATE != "" ]]; then
		echo "Attempting to reset submodule $DIR2UPDATE"
		cd $PARENTDIR/$DIR2UPDATE/..
		while [[ ! -d .git ]]; do
			cd ../
		done
		git submodule init
		git submodule update
		cd $PARENTDIR/$DIR2UPDATE
		git reset --hard HEAD
		git clean -d -x -f
		git checkout master
		git pull
		cd ..
		while [[ ! -d .git ]]; do
			cd ../
		done
		echo "Committing changes to $PWD"
#		git commit -a -m "Reset submodule to latest HEAD"
		git add $PARENTDIR/$DIR2UPDATE
		git commit $PARENTDIR/$DIR2UPDATE -m "Reset submodule $DIR2UPDATE to latest HEAD"
		git push origin master
	fi
done
exec 3>&-

# Let the disk subsystem recover
sleep 60

rm /var/lock/update-tde-git-submodules