2021-01-07 08:09:41 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-05-09 11:00:44 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
UNAME=$(sh -c 'uname 2>/dev/null || echo Unknown')
|
2022-07-12 07:53:37 +00:00
|
|
|
declare -A SKIP=()
|
|
|
|
POSITIONAL=()
|
|
|
|
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
|
key="$1"
|
|
|
|
|
|
|
|
case $key in
|
|
|
|
-s|--skip)
|
|
|
|
shift # past argument
|
|
|
|
SKIP["$1"]=1
|
|
|
|
shift # past value
|
|
|
|
;;
|
|
|
|
*) # unknown option
|
|
|
|
POSITIONAL+=("$1") # save it in an array for later
|
|
|
|
shift # past argument
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
declare -A RUN=()
|
|
|
|
|
2022-07-12 08:48:59 +00:00
|
|
|
for command in "pacman" "apt" "dnf" "flatpak" "gem" "nvim" "asdf" "brew" "pacman";
|
2022-07-12 07:53:37 +00:00
|
|
|
do
|
|
|
|
echo $command
|
|
|
|
if type $command > /dev/null 2>&1
|
|
|
|
then
|
|
|
|
if [ "${SKIP[$command]}" = "1" ]; then
|
|
|
|
RUN[$command]=0
|
|
|
|
else
|
|
|
|
RUN[$command]=1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
RUN[$command]=0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Special case for vim
|
|
|
|
if type -f vim > /dev/null 2>&1
|
|
|
|
then
|
|
|
|
if [ "${SKIP[vim]}" = "1" ]; then
|
|
|
|
RUN[vim]=0
|
|
|
|
else
|
|
|
|
RUN[vim]=1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
RUN[vim]=0
|
|
|
|
fi
|
2022-05-09 11:00:44 +00:00
|
|
|
|
2022-07-12 07:53:37 +00:00
|
|
|
if [ "${RUN[pacman]}" = "1" ]
|
2021-01-07 08:09:41 +00:00
|
|
|
then
|
|
|
|
# Clear out orphans
|
|
|
|
sudo pacman -Rns $(pacman -Qtdq)
|
|
|
|
|
|
|
|
# Update arch packages
|
|
|
|
sudo pacman -Syu
|
|
|
|
|
|
|
|
# Update AUR packages
|
2022-05-09 16:02:15 +00:00
|
|
|
aurfetch update-all -q
|
2021-01-07 08:09:41 +00:00
|
|
|
fi
|
|
|
|
|
2022-07-12 07:53:37 +00:00
|
|
|
if [ "${RUN[apt]}" = "1" ]
|
2021-01-07 08:09:41 +00:00
|
|
|
then
|
|
|
|
# Clear out orphans
|
|
|
|
sudo apt autoremove
|
|
|
|
|
|
|
|
# Update apt packages
|
|
|
|
sudo apt update
|
|
|
|
sudo apt full-upgrade
|
|
|
|
|
|
|
|
# Clear out orphans
|
|
|
|
sudo apt autoremove
|
|
|
|
fi
|
|
|
|
|
2022-07-12 08:48:59 +00:00
|
|
|
if [ "${RUN[dnf]}" = "1" ]
|
|
|
|
then
|
|
|
|
# Clear out orphans
|
|
|
|
sudo dnf autoremove
|
|
|
|
|
|
|
|
# Update dnf packages
|
|
|
|
sudo dnf update
|
|
|
|
|
|
|
|
# Clear out orphans
|
|
|
|
sudo dnf autoremove
|
|
|
|
fi
|
|
|
|
|
2022-07-12 07:53:37 +00:00
|
|
|
if [ "${RUN[flatpak]}" = "1" ]
|
2021-01-07 08:09:41 +00:00
|
|
|
then
|
|
|
|
# Clear out unused flatpak apps
|
|
|
|
flatpak uninstall --unused
|
|
|
|
|
|
|
|
# Update flatpak packages
|
|
|
|
flatpak update
|
|
|
|
|
|
|
|
# Clear out unused flatpak apps once again
|
|
|
|
flatpak uninstall --unused
|
|
|
|
fi
|
|
|
|
|
2022-07-12 07:53:37 +00:00
|
|
|
if [ "${RUN[gem]}" = "1" ]
|
2022-05-09 11:00:44 +00:00
|
|
|
then
|
|
|
|
gem update --system
|
|
|
|
gem update
|
|
|
|
fi
|
2021-01-07 08:09:41 +00:00
|
|
|
|
2022-07-12 07:53:37 +00:00
|
|
|
if [ "${RUN[nvim]}" = "1" ]
|
2022-05-09 11:00:44 +00:00
|
|
|
then
|
|
|
|
nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
|
|
|
|
fi
|
|
|
|
|
2022-07-12 07:53:37 +00:00
|
|
|
if [ "${RUN[vim]}" = "1" ]
|
2022-05-09 11:00:44 +00:00
|
|
|
then
|
|
|
|
command vim +PlugUpdate +qall
|
|
|
|
fi
|
|
|
|
|
2022-07-12 07:53:37 +00:00
|
|
|
if [ "${RUN[asdf]}" = "1" ]
|
2022-05-09 11:00:44 +00:00
|
|
|
then
|
|
|
|
asdf update
|
|
|
|
asdf plugin-update --all
|
2022-05-10 18:26:55 +00:00
|
|
|
|
2022-06-29 15:42:36 +00:00
|
|
|
echo "========== ASDF UPDATES =========="
|
|
|
|
echo "Available updates: "
|
|
|
|
while IFS= read -r PKG; do
|
|
|
|
if [ $(echo "$PKG" | cut -f3) = "missing" ]; then
|
|
|
|
PKG_NAME=$(echo "$PKG" | cut -f1)
|
|
|
|
if [ "$PKG_NAME" != "java" -a "$PKG_NAME" != "ruby" ]; then
|
|
|
|
PKG_VER=$(echo $PKG | cut -f2)
|
|
|
|
echo " $PKG_NAME - $PKG_VER (install with 'asdf install $PKG_NAME $PKG_VER' and set as global default with 'asdf global $PKG_NAME $PKG_VER')"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done <<< "$(asdf latest --all)"
|
|
|
|
echo "========== ASDF UPDATES =========="
|
2022-05-09 11:00:44 +00:00
|
|
|
fi
|
|
|
|
|
2022-07-12 07:53:37 +00:00
|
|
|
if [ "${RUN[brew]}" = "1" ]
|
2022-05-09 11:00:44 +00:00
|
|
|
then
|
|
|
|
brew update
|
|
|
|
brew upgrade
|
|
|
|
if [ "$UNAME" = "Darwin" ]; then
|
|
|
|
brew upgrade --cask
|
|
|
|
fi
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo $( date +%s ) > $MY_CONFIG_CACHE_DIR/brew-upgrade-date
|
|
|
|
fi
|
|
|
|
fi
|
2021-01-07 08:09:41 +00:00
|
|
|
|
2022-07-12 07:53:37 +00:00
|
|
|
if [ "${RUN[pacman]}" = "1" ]
|
2021-01-07 08:09:41 +00:00
|
|
|
then
|
|
|
|
# Clear out orphans once again
|
|
|
|
sudo pacman -Rns $(pacman -Qtdq)
|
|
|
|
fi
|