This repository has been archived by the owner on Sep 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
5_configure_git.sh
101 lines (83 loc) · 1.42 KB
/
5_configure_git.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#! /bin/bash
SCRIPT=`basename $0`
ERROR=1
SUCCESS=0
SEPERATOR="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
ENT_ID=""
ACN_EMAIL="@accenture.com"
usage()
{
echo "$SCRIPT: usage: "
}
config_git()
{
git config --global user.name \""$1\""
if [ $? -eq 0 ]
then
git config --global user.email \""$1$ACN_EMAIL\""
else
return $ERROR
fi
return $SUCCESS
}
config_ssh()
{
ssh-keygen -t rsa -C $ENT_ID$ACN_EMAIL
if [ $? -ne 0 ]
then
RET_CODE=$ERROR
else
RET_CODE=$SUCCESS
fi
return $RET_CODE
}
if [ `id -u` -eq 0 ]
then
echo "$SCRIPT: ERROR: Script cannot be run as root or with sudo."
exit $ERROR
fi
if ( ! getopts ":hu:" opt; )
then
usage
exit $SUCCESS
fi
while getopts :hu: opt; do
case $opt in
h)
usage
exit $SUCCESS
;;
u)
ENT_ID="$OPTARG"
;;
\?)
echo "$SCRIPT: Invalid option: -$OPTARG" >&2
usage
exit $ERROR
;;
:)
echo "$SCRIPT: Option -$OPTARG requires an enterprise id sans @accenture.com." >&2
usage
exit $ERROR
;;
esac
done
echo "$SCRIPT: Configuring git."
config_git $ENT_ID
if [ $? -eq 0 ]
then
echo "$SCRIPT: git configured successfully."
else
echo "$SCRIPT: ERROR: git was not configured." >&2
exit $ERROR
fi
echo "$SCRIPT: creating ssh keys for $ENT_ID$ACN_EMAIL."
config_ssh
if [ $? -eq 0 ]
then
echo "$SCRIPT: keys generated successfully."
else
echo "$SCRIPT: ERROR: keys failed to generate." >&2
exit $ERROR
fi
exit $SUCCESS