-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupgrade_all.sh
More file actions
executable file
·93 lines (69 loc) · 2.45 KB
/
upgrade_all.sh
File metadata and controls
executable file
·93 lines (69 loc) · 2.45 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
#!/usr/bin/env bash
set -e
# Aliases and custom functions
source "$HOME"/dotfiles/colors.sh
source "$HOME"/dotfiles/utils.sh
function check_if_wsl_needs_upgrade() {
echo "Checking Windows Subsystem for Linux status..."
local update_command_output
update_command_output=$(wsl.exe --update 2>&1 | tr -d '\000')
if echo "$update_command_output" | grep -qi "is already installed"; then
echo "✅ Windows Subsystem for Linux is already up to date."
else
echo "⚡ Windows Subsystem for Linux has an available update."
echo "Run the following command to upgrade:"
echo "wsl.exe --update"
fi
}
function upgrade_all() {
export DEBIAN_FRONTEND=noninteractive
pushd ~ &>/dev/null || exit # to correctly update global NPM packages
# macOS
if [[ "$UNAME_OUTPUT" == 'Darwin' ]]; then
# This sometimes breaks Homebrew taps upgrade
# upgrade_xcode
# echo "Updating macOS (if updates available)"
# softwareupdate -i -a
upgrade_packages_mac
# Do the rest without sudo
sudo --reset-timestamp
fi
# WSL 2
if test -f /proc/sys/kernel/osrelease &&
grep -q microsoft /proc/sys/kernel/osrelease; then
check_if_wsl_needs_upgrade
# Run it first as it requires sudo
upgrade_apt_packages
echo "Upgrading WSL packages..."
# Close Visual Studio Code beforehand (winget will request to close it via GUI otherwise)
if tasklist.exe | grep Code.exe; then
taskkill.exe /F /IM Code.exe
fi
exec_powershell_script ~/dotfiles/windows/UpgradeWingetPackages.ps1
fi
echo "Upgrading oh-my-zsh..."
source "$HOME"/dotfiles/install/update_oh_my_zsh.sh
echo "Upgrading Vim plugins..."
vim -i NONE -c PlugUpdate -c quitall &>/dev/null
echo "Upgrading npm packages..."
# The following command sometimes doesn't work:
# npx npm-check --global --update-all
# So instead we remove all the packages and do a fresh install:
source "$HOME"/dotfiles/paths
rm --recursive --force "$NPM_GLOBAL_PACKAGES_DIRECTORY"
upgrade_npm_packages
echo "Upgrading pipx packages..."
# Running it twice seems to resolve some dependency issues which PIP reports when running it just one time
upgrade_pipx_packages
popd &>/dev/null || exit
# macOS
if [[ "$UNAME_OUTPUT" == 'Darwin' ]]; then
"$HOME"/dotfiles/mac/post_install.sh
# Do the rest without sudo
sudo --reset-timestamp
fi
# TODO: Upgrade other dotfiles/install packages the same way
"$HOME"/dotfiles/install/install_yt-dlp.sh
printf "Upgraded all applications on %s\n" "$(date)" >>~/update_log.txt
}
upgrade_all