-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdash.sh
executable file
·361 lines (316 loc) · 7.95 KB
/
dash.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
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
#! /bin/bash
### Dev Automation Script for automating git and docker ###
### Created by PIYUSH-MISHRA-00 ###
while :
do
echo
echo "Which operation you want to perform ?"
echo
echo -e "\t(0) VOICE"
echo -e "\t(1) GitHub"
echo -e "\t(2) Docker"
echo -e "\t(3) Quit"
echo -n "Enter your choice [0-3]: "
read operation
export operation
case $operation in
0) echo "Initializing VOICE"
python3 VOICE.py
;;
1) while :
do
echo
echo "Which Git operation you want to perform ?"
echo
echo "GitHub username: $username"
echo "Local repository name: $local_repo"
echo "Remote repository name: $remote"
echo "The default branch you want to work with: $branch"
echo "GPG key value: $GPG"
echo
echo -e "\t(0) Configure (configures the script for continuous uses)"
echo -e "\t(1) Clone"
echo -e "\t(2) Pull"
echo -e "\t(3) Push"
echo -e "\t(4) Generate Patch"
echo -e "\t(5) Send Email"
echo -e "\t(6) Return to Main Menu"
echo -n "Enter your choice [0-6]: "
read choice
case $choice in
0) echo "Enter the values for future use of the script..."
echo
echo "Enter GitHub username: "
read username
export username
echo "Your username is: $username"
echo
echo "Local repository name: "
read local_repo
export local_repo
echo "Your local repository name is: $local_repo"
echo
echo "Remote repository name: "
read remote
export remote
echo "Remote repository name is: $remote"
echo
echo "The default branch you want to work with: "
read branch
export branch
echo "The default branch you want to work with: $branch"
echo
echo "GPG key value is: $GPG"
echo
echo "GPG key id for signed commits(leave blank if you don't want signed commits)"
read GPG
export GPG
echo "GPG key value is: $GPG"
echo
;;
1) echo "Cloning from GitHub"
echo
echo "Enter the repository https url: "
read clone_url
git clone $echo $clone_url;;
2) echo "Pulling from GitHub"
echo
echo "Enter the repository https url: "
read pull_url
echo
echo $pull_url
echo
while :
do
echo "Which type of Git Pull you want ?"
echo -e "\t(1) Merge (the default strategy)"
echo -e "\t(2) Rebase"
echo -e "\t(3) Fast-forward only"
echo -e "\t(4) Return to main menu"
echo -n "Enter your choice [1-4]: "
read pull_choice
case $pull_choice in
1)
git config pull.rebase false
git pull $echo "$pull_url";;
2)
git config pull.rebase true
git pull $echo "$pull_url";;
3)
git config pull.ff only
git pull $echo "$pull_url";;
4)
break
;;
*)
echo "Invalid operation"
;;
esac
done
;;
3) echo "Pushing to GitHub"
echo
while :
do
echo "Which type of Git Push you want ?"
echo -e "\t(0) LFS (if git lfs is already installed into the system)"
echo -e "\t(1) Normal"
echo -e "\t(2) Return to main menu"
echo -n "Enter your choice [0-2]: "
read push_choice
case $push_choice in
0)
declare -A map
map[$echo"$local_repo"] = $echo"$remote"
git config --global user.name $echo"$username"
git config --global user.signingkey $echo$GPG
git init
git lfs install
echo
echo "Enter the file extension without dot"
read extension
export extension
git lfs track "*.$extension"
git add .gitattributes
git add .
echo "Enter Commit message: "
read message
git commit -m $echo "$message"
echo "Enter Tag name: (Press enter if you want to skip the tag name)"
read tag
echo "Enter Tag message: (Press enter if you want to skip the tag message)"
read tag_message
git tag -a $echo$tag -m "$echo$tag_message"
git tag -n
for i in "${!map[@]}"
do
git remote add $i https://github.com/$echo$username/${map[$i]}.git
git push -u $i $echo$branch
done
git push;;
1)
declare -A map
map[$echo"$local_repo"] = $echo"$remote"
git config --global user.name $echo"$username"
git config --global user.signingkey $echo$GPG
git init
git add .
echo "Enter Commit message: "
read message
git commit -m $echo "$message"
echo "Enter Tag name: (Press enter if you want to skip the tag name)"
read tag
echo "Enter Tag message: (Press enter if you want to skip the tag message)"
read tag_message
git tag -a $echo$tag -m "$echo$tag_message"
git tag -n
for i in "${!map[@]}"
do
git remote add $i https://github.com/$echo$username/${map[$i]}.git
git push -u $i $echo$branch
done
git push;;
2)
break
;;
*)
echo "Invalid operation"
;;
esac
done
;;
4) echo "Generate Patch"
echo "Enter file 1 and file 2"
echo "Enter file 1"
read fileone
export fileone
echo "Enter file2"
read filetwo
export filetwo
diff $echo$fileone $echo$filetwo -staged
echo "Enter the file name created using diff"
read file_diff
export file_diff
git patch $file_diff
;;
5) echo "Send Email"
echo "Enter the receiver... ??"
read receiver
echo "File you want to mail ??"
read filename
git send-email --to=$receiver $filename
;;
6)
break
;;
*) echo "Invalid operation"
;;
esac
done
;;
2) while :
do
echo "Which type of Docker operation you want to perform ?"
echo -e "\t(0) Login to the Docker Hub Repository"
echo -e "\t(1) Pull an Image from Docker Hub"
echo -e "\t(2) Build an Image"
echo -e "\t(3) Run a Docker Image"
echo -e "\t(4) Access the running container"
echo -e "\t(5) Remove a Docker Container"
echo -e "\t(6) Remove a Docker Image"
echo -e "\t(7) Push an Image to the docker hub repository"
echo -e "\t(8) Return to main menu"
echo -n "Enter your choice [0-8]: "
read dchoice
case $dchoice in
0)
docker login
;;
1)
echo "Enter Username: "
read pull_username
export pull_username
echo "Enter Image name: "
read image_name
export image_name
echo "Enter tag if specific: "
read pull_tag_name
export pull_tag_name
docker pull $pull_username/$image_name:$pull_tag_name
;;
2)
while :
do
echo "Which docker build you want...?"
echo -e "\t(0) Build from working directory "
echo -e "\t(1) Build from URL"
echo -e "\t(2) Return to main menu"
echo -n "Enter your choice [0-2]: "
read build_choice
export build_choice
case $build_choice in
0)
docker build .
;;
1)
echo "Enter the URL without "https://""
read build_url
export build_url
docker build $build_url
;;
2)
break
;;
*) echo "Invalid operation"
;;
esac
done
;;
3)
echo "Enter image name you want to run: "
read run_image
export run_image
docker run -it -d $run_image
;;
4)
docker login
;;
5)
echo "Enter Container ID to remove: "
read container_id
export container_id
docker rm $container_id
;;
6)
echo "Enter Image ID to remove: "
read image_id
export image_id
docker rmi $image_id
;;
7)
docker login
echo "Enter Docker username: "
read docker_username
export docker_username
echo "Enter docker image name you want to push: "
read push_image_name
export push_image_name
docker push $docker_username/$push_image_name
;;
8)
break
;;
*)
echo "Invalid operation"
;;
esac
done
;;
3) echo "Quitting..."
exit
;;
*) echo "Invalid operation"
;;
esac
done
;;