-
Notifications
You must be signed in to change notification settings - Fork 0
/
new-update-hostname.sh
executable file
·54 lines (48 loc) · 1.16 KB
/
new-update-hostname.sh
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
#!/bin/sh
# Add a bunch of useless comments
# just to change the file
# testing this git setup
# Why do I have to check this myself?
if [ "$1" = "-h" ]
then
echo ""
echo "Usage: update-hostname.sh <path>"
echo ""
echo " The script will recursively search for git repositories under the"
echo " <path> directory and update the configuration file to include the"
echo " new hostname of the Euclid GitLab server."
echo ""
echo " If <path> is left blank, the script will search from the current"
echo " working directory."
echo ""
exit 0
fi
if [ "$1" = "" ]
then
pathtocheck="."
else
pathtocheck=$1
fi
for a in `find $pathtocheck -path \*/.git/config -print`
do
echo "Checking $a"
grep "euclid-git.roe.ac.uk" $a > /dev/null
if [ "$?" -eq "0" ]
then
echo "Updating $a"
backupfile="$a.backup"
mv $a $backupfile
if [ "$?" -gt "0" ]
then
echo "Failed to create backup of $a. Exiting."
exit 1
fi
cat $backupfile | sed 's/euclid-git.roe.ac.uk/gitlab.euclid-sgs.uk/' > $a
if [ "$?" -gt "0" ]
then
echo "Failed to write to $a. Exiting."
exit 1
fi
fi
done
exit 0