dots/install.sh

56 lines
1.6 KiB
Bash
Raw Normal View History

2024-07-29 11:32:52 +00:00
#!/usr/bin/env bash
# Author : Ibrahim Mkusa
# Description: installs and sets up core environment for my dev work on servers
set -e # subshells inherit environment from parent
function usage() {
echo "./install #installs and setups this environment"
echo "./install undo #removes all configs"
echo "./install wipe #removes all configs and removes all installed packages"
}
2024-07-29 11:32:52 +00:00
# detect which family of distro i'm on
if [[ -f /etc/os-release ]]; then
. /etc/os-release
case "$ID_LIKE" in
debian)
2024-08-09 01:38:48 +00:00
echo "Running on debian-family.."
2024-08-08 14:15:11 +00:00
package_manager=apt
2024-08-09 01:38:48 +00:00
vim="vim-nox"
2024-12-04 13:24:44 +00:00
ansible="ansible"
2024-07-29 11:32:52 +00:00
;;
fedora)
2024-12-04 13:24:44 +00:00
echo "Running on rpm-family.."
package_manager=dnf
2024-08-09 01:38:48 +00:00
vim="vim-enhanced"
2024-12-04 13:24:44 +00:00
ansible="ansible-core"
2024-07-29 11:32:52 +00:00
esac
else
echo "You are running an unrecognized family of os. Quitting..."
exit 1
fi
# could have used a case, but i prefer the if statement
if [[ -z "$1" ]]; then
echo "Installing packages"
2024-12-04 13:24:44 +00:00
sudo "$package_manager" install -y "$vim" git stow curl ranger tmux "$ansible"
# backup current configs
mv ~/.bashrc ~/.bashrc.bak;mv ~/.bash_profile ~/.bash_profile.bak
# use gnu stow to symlink config files to home directory
2024-12-04 13:24:44 +00:00
stow bash ranger shellenv tmux vim
elif [[ undo = "$1" ]]; then
echo "undoing"
stow -D bash git ranger shellenv tmux vim
elif [[ wipe = "$1" ]]; then
stow -D bash git ranger shellenv tmux vim
sudo "$package_manager" remove "$vim" git stow curl ranger tmux
echo "wiping"
elif [[ "$1" = "help" ]]; then
usage
fi
2024-12-04 13:24:44 +00:00
# extras for tmux
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm || true