feat: evolve manage script

This commit is contained in:
drymer 2021-08-25 00:04:37 +02:00
parent 3357152a61
commit 2f4cca286e

View file

@ -3,11 +3,8 @@ set -eo pipefail
arg=$1
if [[ $arg == "packages-bundle" ]]
if [[ $arg == "install-packages" ]]
then
# Actualizar repositorios
sudo pacman -Sy
# Instalar yay
if ! command -v yay &> /dev/null
then
@ -34,17 +31,49 @@ then
sudo chown -R $(whoami).users /opt/brew/
fi
# Instalar oh-my-zsh
if [[ ! -d $HOME/.oh-my-zsh ]]; then
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi
echo Todo está instalado.
elif [[ $arg == "diff-bundle" ]]
then
# Guarda los paquetes actuales, si hay diferencias creará un 99-unsorted.sh
echo Comprobando los paquetes del sistema...
aconfmgr -c packages/arch save 2> /dev/null
if [[ -e packages/arch/99-unsorted.sh ]]
then
echo Hay diferencias en los paquetes instalados, deberias quitarlos o añadirlos a los demás ficheros. Cuando estés, borra el fichero de unsorted.
cat packages/arch/99-unsorted.sh
fi
# Guarda los paquetes de brew actuales
brew bundle dump --force --file /tmp/Brewfile
# No se puede controlar que diff "falle" cuando hay diferencias, así que desactivamos ese control temporalmente
set +e
brew_diffs=$(diff -q /tmp/Brewfile packages/brew/Brewfile)
set -e
if [[ -n $brew_diffs ]]
then
echo $brew_diffs
echo Si estás de acuerdo con los cambios, puedes guardarlos ejecutando "brew bundle dump --force --file packages/brew/Brewfile"
echo Si no lo estás, ejecuta "brew bundle --file packages/brew/Brewfile --force cleanup"
fi
elif [[ $arg == "apply-bundle" ]]
then
# Actualizar repositorios
sudo pacman -Sy
# Instalar paquetes del sistema
aconfmgr -c packages/arch apply
# Instalar paquetes de brew
brew bundle --file packages/brew/Brewfile
brew bundle install --file packages/brew/Brewfile
# Instalar oh-my-zsh
if [[ -a $HOME/.oh-my-zsh ]]; then
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi
elif [[ $arg == "packages-update" ]]
elif [[ $arg == "update-bundle" ]]
then
# Actualiza oh my zsh
sh "$HOME/.oh-my-zsh/tools/upgrade.sh"
@ -52,21 +81,20 @@ then
# Actualiza arch
sudo pacman -Syu
# Sincroniza los repositorios de brew
brew update
# Actualiza los paquetes instalados
brew upgrade
elif [[ $arg == "dotfiles" ]]
then
cd dotfiles
stow -t ~ alacritty
stow -t ~ git
stow -t ~ i3
stow -t ~ shells
stow -t ~ starship
sudo stow -t / system-configurations
cd ..
else
echo "use 'packages-bundle', 'packages-update' or 'dotfiles'"
echo "Usa 'install-packages', 'diff-bundle', 'apply-bundle', 'update-bundle' o 'dotfiles'"
fi