-
Notifications
You must be signed in to change notification settings - Fork 0
/
repo.sh
executable file
·56 lines (48 loc) · 1.15 KB
/
repo.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
#!/bin/bash
# Set Colors
bold=$(tput bold)
underline=$(tput sgr 0 1)
reset=$(tput sgr0)
purple=$(tput setaf 171)
red=$(tput setaf 1)
green=$(tput setaf 76)
tan=$(tput setaf 3)
blue=$(tput setaf 38)
# Logging Functions
e_header() {
printf "\n%s========== %s ==========%s\n" "$bold$purple" "$@" "$reset"
}
e_success() {
printf "%s✔ %s%s\n" "$green" "$@" "$reset"
}
e_error() {
printf "%s✖ %s%s\n" "$red" "$@" "$reset"
}
e_warning() {
printf "%s➜ %s%s\n" "$tan" "$@" "$reset"
}
e_note() {
printf "%s%sNote:%s %s%s%s\n" "$underline$bold$blue" "$reset" "$blue" "$@" "$reset"
}
# Header
e_header "Application"
# Confirm action
read -p "$(e_warning "Would you like to update the repository? (y/n) ")" -n 1
printf "\n"
if [[ $REPLY =~ ^[Yy]$ ]]; then
# Set up SSH agent
eval "$(ssh-agent -s)"
ssh-add $HOME/.ssh/2_rsa
e_success "SSH agent has been registered!"
# Update repository
cd $HOME/blog/
e_success "Fetching origin changes..."
git fetch origin
git merge origin/main
e_success "Merge completed successfully!"
# Cleanup SSH agent
trap "kill $SSH_AGENT_PID" EXIT
e_success "SSH agent killed!"
else
e_error "Updates canceled!"
fi