forked from denysdovhan/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate
executable file
·132 lines (105 loc) · 2.44 KB
/
update
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
#!/usr/bin/env bash
# Get System Updates, update NPM packages and dotfiles
# Source: https://github.com/sapegin/dotfiles/blob/master/setup/update.sh
trap on_error SIGTERM
e='\033'
RESET="${e}[0m"
BOLD="${e}[1m"
CYAN="${e}[0;96m"
RED="${e}[0;91m"
YELLOW="${e}[0;93m"
GREEN="${e}[0;92m"
_exists() {
command -v "$1" > /dev/null 2>&1
}
# Success reporter
info() {
echo -e "${CYAN}${*}${RESET}"
}
# Error reporter
error() {
echo -e "${RED}${*}${RESET}"
}
# Success reporter
success() {
echo -e "${GREEN}${*}${RESET}"
}
# End section
finish() {
success "Done!"
echo
sleep 1
}
# Set directory
export DOTFILES=${1:-"$HOME/.dotfiles"}
on_start() {
info ' __ __ ____ _ __ '
info ' ____/ /____ / /_ / __/(_)/ /___ _____ '
info ' / __ // __ \ / __// /_ / // // _ \ / ___/ '
info ' _ / /_/ // /_/ // /_ / __// // // __/(__ ) '
info ' (_)\__,_/ \____/ \__//_/ /_//_/ \___//____/ '
info ' '
info ' by @denysdovhan '
info ' '
}
update_dotfiles() {
info "Updating dotfiles..."
cd "$DOTFILES" || exit
git pull origin master
./install --except shell
cd - > /dev/null 2>&1 || exit
info "Updating Zsh plugins..."
zgen selfupdate
zgen update
finish
}
update_brew() {
if ! _exists brew; then
return
fi
info "Updating Homebrew..."
brew update
brew upgrade
brew cleanup
finish
}
update_apt_get() {
if ! _exists apt; then
return
fi
info "Updating Ubuntu and installed packages..."
sudo apt update
sudo apt upgrade -y
sudo apt autoremove -y
sudo apt autoclean -y
finish
}
on_finish() {
success "Done!"
success "Happy Coding!"
echo
echo -ne "$RED"'-_-_-_-_-_-_-_-_-_-_-_-_-_-_'
echo -e "$RESET""$BOLD"',------,'"$RESET"
echo -ne "$YELLOW"'-_-_-_-_-_-_-_-_-_-_-_-_-_-_'
echo -e "$RESET""$BOLD"'| /\_/\\'"$RESET"
echo -ne "$GREEN"'-_-_-_-_-_-_-_-_-_-_-_-_-_-'
echo -e "$RESET""$BOLD"'~|__( ^ .^)'"$RESET"
echo -ne "$CYAN"'-_-_-_-_-_-_-_-_-_-_-_-_-_-_'
echo -e "$RESET""$BOLD"'"" ""'"$RESET"
echo
}
on_error() {
error "Wow... Something serious happened!"
error "Though, I don't know what really happened :("
exit 1
}
main() {
echo "Before we proceed, please type your sudo password:"
sudo -v
on_start "$*"
update_dotfiles "$*"
update_brew "$*"
update_apt "$*"
on_finish "$*"
}
main "$*"