-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy path11.Shell script to get all git versions using functions concept.txt
187 lines (93 loc) · 2.85 KB
/
11.Shell script to get all git versions using functions concept.txt
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#Please complete function concept first and then come back here
#!/bin/bash
#Author: Narendra
#Version: 1.0
COLUMNS=$(tput cols)
prRed(){
echo -e "\033[91m$1 \033[00m"
}
prGreen(){
echo -e "\033[92m$1 \033[00m"
}
prYellow(){
echo -e "\033[93m$1 \033[00m"
}
prPurple(){
echo -e "\033[95m$1 \033[00m"
}
prCyan(){
echo -e "\033[96m$1 \033[00m"
}
prHeader(){
for each in $(seq 1 $COLUMNS)
do
echo -n $1
done
}
prtxtCentre(){
title=$1
printf "%*s\n" $(((${#title}+$COLUMNS)/2)) "$title"
}
download_git_versions_info(){
GIT_VERS_URL="https://mirrors.edge.kernel.org/pub/software/scm/git/"
GIT_VERS_FILE="git_vers_info.html"
if [ -e "${GIT_VERS_FILE}" ]
then
prYellow "Found old ${GIT_VERS_FILE}.Deleting this old file and downloading new content.Please wait..."
rm -rf ${GIT_VERS_FILE}
else
prGreen "Downloading git vers info. Please wait..."
fi
which wget 1>/dev/null 2>&1
if [ $? -ne 0 ]
then
prRed "Sorry unable to download , wget command is not installed on this host. Please install it and retry"
exit 2
fi
wget ${GIT_VERS_URL} --output-document=${GIT_VERS_FILE} 1>/dev/null 2>&1
if [ $? -ne 0 ]
then
prRed "Unable to download. Please try the below command manually and verify"
prRed "wget ${GIT_VERS_URL} --output-document=${GIT_VERS_FILE}"
else
prGreen "Successfully downloaded git vers info from git-scm and stored the info into a file: ${GIT_VERS_FILE}"
fi
}
diplay_all_available_git_versions(){
if [ ! -e ${GIT_VERS_FILE} ]
then
prRed "Unable to find the ${GIT_VERS_FILE}"
fi
prPurple "Sorting git versions. Please wait..."
while read line
do
git_vers+=($(echo $line | sed -n '/git-\([0-9]\+\.\)\+tar.gz/p'|awk -F '"' '{ print $2 }'|cut -c 5- | awk -F '.tar.gz' '{ print $1}'))
done < ${GIT_VERS_FILE}
#echo ${#git_vers[@]}
prHeader "="
prtxtCentre "Displaying all available git versions"
cnt=0
no_vers=${#git_vers[*]}
WIDTH=14
prHeader "="
for each_ver in ${git_vers[*]}
do
printf "%-*s %-*s %-*s %-*s %-*s %-*s %-*s %-*s\n" $WIDTH ${git_vers[$cnt]} $WIDTH ${git_vers[$((cnt+1))]} $WIDTH ${git_vers[$((cnt+2))]} $WIDTH ${git_vers[$((cnt+3))]} $WIDTH ${git_vers[$((cnt+4))]} $WIDTH ${git_vers[$((cnt+5))]} $WIDTH ${git_vers[$((cnt+6))]} $WIDTH ${git_vers[$((cnt+7))]}
cnt=$((cnt+8))
if [ $cnt -ge $no_vers ]
then
break
fi
done
prHeader "_"
}
main() {
clear
prHeader "="
prtxtCentre "Welcome to Automate Git installation using shell script"
prHeader "="
prCyan "Checking all available git versions from official git-scm websites. Please wait...."
download_git_versions_info
diplay_all_available_git_versions
}
main