-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsysupdate.sh
More file actions
executable file
·152 lines (135 loc) · 3.31 KB
/
sysupdate.sh
File metadata and controls
executable file
·152 lines (135 loc) · 3.31 KB
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
#!/bin/bash
SCRIPTS_SRC="$(dirname "${BASH_SOURCE[0]}")"
DOTFILES_SRC="${HOME}/src/dotfiles"
ARTISAN_SRC="${HOME}/src/artisan"
function notify {
script_name="$(basename "$0")"
message="${1}"
urgency="${2:-low}"
notify-send "${script_name}" "${message}" -u "${urgency}"
}
function update_system {
os=$(hostnamectl status --json=short | jq -r '.OperatingSystemPrettyName')
case "$os" in
Gentoo*)
update_gentoo
return $?
;;
Ubuntu*)
update_ubuntu
return $?
;;
*)
echo "Updating ${os} systems is not implemented" >&2
return 1
esac
}
function update_dotfiles_dependencies {
cd ${DOTFILES_SRC}
pip3 install -U --user -r requirements.txt
status=$?
cd -
return $status
}
function update_script_dependencies {
cd ${SCRIPTS_SRC}
pipenv update
status=$?
cd -
return $status
}
function update_nvim {
nvim -c PlugUpdate -c quitall
return $?
}
function update_kali {
cd "${SCRIPTS_SRC}/kali"
make update
status=$?
cd -
return $status
}
function update_k9s {
LATEST_VERSION=$(curl --silent 'https://api.github.com/repos/derailed/k9s/releases/latest' | jq -r .tag_name)
CURRENT_VERSION=$(k9s version -s | grep Version | awk '{print "v"$2}')
if [ "${LATEST_VERSION}" != "${CURRENT_VERSION}" ]; then
DOWNLOAD_URL=$(curl --silent 'https://api.github.com/repos/derailed/k9s/releases/latest' | jq -r '.assets[] | select(.name == "k9s_Linux_amd64.tar.gz").browser_download_url')
curl -L "${DOWNLOAD_URL}" | tar xzvf - -C "$(dirname $(which k9s))" k9s;
return $?
fi
return 0
}
function update_artisan {
cd "${ARTISAN_SRC}"
make build-latest
}
function update_ubuntu {
sudo apt update && \
sudo apt -y upgrade && \
sudo apt dist-upgrade && \
sudo apt -y autoremove
return $?
}
function update_gentoo {
sudo emerge --sync && \
sudo emerge -uaDvN --with-bdeps=y world && \
sudo emerge --depclean
sudo eclean distfiles
sudo eclean packages
return $?
}
function update_flutter {
flutter upgrade -f
return $?
}
function update_android_sdk {
$HOME/Android/Sdk/cmdline-tools/latest/bin/sdkmanager --update
}
function update_all {
update_system || notify "System update failed" "critical"
update_dotfiles_dependencies || notify "dotfiles update failed" "critical"
update_script_dependencies || notify "scripts update failed" "critical"
update_nvim || notify "neovim update failed" "critical"
update_kali || notify "kali update failed" "critical"
update_k9s || notify "k9s update failed" "critical"
update_artisan || notify "artisan update failed" "critical"
update_android_sdk || notify "android sdk update failed" "critical"
update_flutter || notify "flutter update failed" "critical"
notify "System update finished"
}
COMMAND="${1-all}"
case "update_${COMMAND}" in
"update_all")
update_all
;;
"update_system")
update_system
;;
"update_dotfiles_dependencies")
update_dotfiles_dependencies
;;
"update_script_dependencies")
update_script_dependencies
;;
"update_nvim")
update_nvim
;;
"update_kali")
update_kali
;;
"update_k9s")
update_k9s
;;
"update_artisan")
update_artisan
;;
"update_android_sdk")
update_android_sdk
;;
"update_flutter")
update_flutter
;;
*)
echo "${COMMAND} is not implemented"
exit 1
esac