dotfiles/provision_debian

312 lines
9.1 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env fish
# Source: https://github.com/mitchell/run.fish
### Config ###
# Top-level configurations, like function prefixes and argument delimeters
#
set -g run_func_prefix 'provision'
set -g run_arg_delimeter ':'
function define_aliases
end
### Commands ###
# Add, edit, and remove commands freely below.
# To add a command simply create a function with this naming scheme: {run_func_prefix}_{name}.
#
function provision_m_env -d 'Provision m environment (fish, git, neovim, etc.)'
log "Provisioning m's environment." head
log 'Installing git, neovim, tmux, rsync, curl, and kitty-terminfo...'
sudo apt-get update >/dev/null 2>&1
sudo apt-get install --yes \
git \
neovim \
tmux \
rsync \
curl \
kitty-terminfo \
>/dev/null 2>&1
log 'Installing fzf, silversearcher, bat, and feh.'
sudo apt-get install --yes fzf silversearcher-ag bat feh >/dev/null 2>&1
log 'Adding fish apt repo and install fish...'
sudo apt-get install --yes gpg >/dev/null 2>&1
echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_10/ /' |
sudo tee /etc/apt/sources.list.d/shells:fish:release:3.list
curl -fsSL https://download.opensuse.org/repositories/shells:fish:release:3/Debian_10/Release.key |
gpg --dearmor |
sudo apt-key add -
sudo apt-get update >/dev/null 2>&1
sudo apt-get install --yes fish >/dev/null 2>&1
log "Setting m's default shell to fish"
sudo chsh -s /usr/bin/fish m
log 'Running dotfiles sync script.'
./sync
log 'Installing asdf-vm.'
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.7.8 >/dev/null 2>&1
log "Done provisioning m's environment." tail
end
function provision_desktop_env -d 'Provision bspwm based desktop environment'
log 'Provisioning desktop environment.' head
log 'Installing window manager and compositor.'
sudo apt-get update >/dev/null 2>&1
sudo apt-get install --yes bspwm sxhkd picom >/dev/null 2>&1
log 'Installing terminal.'
sudo apt-get install --yes kitty >/dev/null 2>&1
log 'Installing panel.'
sudo apt-get install --yes xfce4-panel xfce4-pulseaudio-plugin >/dev/null 2>&1
log 'Installing and configuring xinit and xclip.'
sudo apt-get install --yes xinit xclip >/dev/null 2>&1
echo 'exec bspwm' >~/.xinitrc
log 'Installing browser.'
sudo apt-get install --yes qutebrowser >/dev/null 2>&1
log 'Installing application launcher.'
sudo apt-get install --yes rofi >/dev/null 2>&1
log 'Installing theme and fonts.'
mkdir ./nordic; and cd ./nordic
wget -q -O nordic.tar.xz https://github.com/EliverLara/Nordic/releases/download/v1.9.0/Nordic.tar.xz
tar -xf ./nordic.tar.xz
mkdir ~/.themes
mv ./Nordic/ ~/.themes/
cd ..; and rm -r ./nordic
sudo apt-get install --yes fonts-ibm-plex unzip >/dev/null 2>&1
log 'Installing desktop background manager.'
sudo apt-get install --yes feh >/dev/null 2>&1
log 'Installing screen saver.'
sudo apt-get install --yes xfce4-screensaver >/dev/null 2>&1
log 'Installing JetBrainsMono.'
mkdir _fonts_tmp
cd _fonts_tmp
wget -q https://github.com/JetBrains/JetBrainsMono/releases/download/v2.002/JetBrainsMono-2.002.zip
unzip JetBrainsMono-2.002.zip >/dev/null
mkdir -p ~/.local/share/fonts/truetype/JetBrainsMono
cp ./ttf/*.ttf ~/.local/share/fonts/truetype/JetBrainsMono/
cd ..
rm -r _fonts_tmp
log 'Configure GTK theme and font.'
mkdir -p ~/.config/gtk-3.0
echo "
[Settings]
gtk-icon-theme-name = Adwaita
gtk-theme-name = Nordic
gtk-font-name = IBM Plex Sans 11" >~/.config/gtk-3.0/settings.ini
log 'Done provisioning desktop environment.' tail
end
function provision_m_net -d 'Provision applications to join m-net'
log 'Provisioning m-net.' head
sudo apt-get update >/dev/null 2>&1
log 'Installing keepassxc.'
sudo apt-get install --yes keepassxc >/dev/null 2>&1
log 'Installing syncthing.'
sudo apt-get install --yes syncthing >/dev/null 2>&1
sudo systemctl enable syncthing@m
log 'Done provisioning desktop environment.' tail
end
function provision_libvirt -d 'Provision libvirt and virt-manager'
log 'Provisioning Libvirt and KVM.' head
sudo apt-get update >/dev/null 2>&1
sudo apt-get install --yes \
qemu-system \
libvirt-clients \
libvirt-daemon-system \
virt-manager \
>/dev/null 2>&1
sudo adduser m libvirt
log 'Done provisioning Libvirt and KVM' tail
end
function provision_vagrant -d 'Provision vagrant with libvirt plugin'
log 'Provisioning vagrant and the libvirt provider.' head
sudo apt-get update >/dev/null 2>&1
log 'Installing vagrant from apt'
sudo apt-get install --yes vagrant-libvirt libvirt-daemon-system >/dev/null 2>&1
log 'Installing vagrant libvirt provider.'
vagrant plugin install vagrant-libvirt
log 'Done provisioning vagrant and libvirt provider.' tail
end
function provision_docker -d 'Provision docker and docker-compose'
log 'Provisioning Docker CE and Docker Compose.' head
log 'Installing docker dependencies.'
sudo apt-get update >/dev/null 2>&1
sudo apt-get install --yes \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common \
>/dev/null 2>&1
log 'Adding Docker apt repo and install docker-ce.'
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
sudo add-apt-repository \
'deb [arch=amd64] https://download.docker.com/linux/debian
buster
stable'
sudo apt-get update >/dev/null 2>&1
sudo apt-get install --yes docker-ce docker-ce-cli containerd.io >/dev/null 2>&1
log 'Installing docker-compose.'
set uname_m (uname -m)
set uname_s (uname -s)
sudo curl \
-L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$uname_s-$uname_m" \
-o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
log 'Adding m to docker group.'
sudo adduser m docker
log 'Done provisioning Docker CE and Docker Compose.' tail
end
function provision_wireguard -d 'Provision wireguard'
log 'Provisioning Wireguard.' head
log 'Installing wireguard and resolvconf.'
set uname_r (uname -r)
sudo apt-get update >/dev/null 2>&1
sudo apt-get install --yes "linux-headers-$uname_r" >/dev/null 2>&1
sudo apt-get install --yes wireguard resolvconf >/dev/null 2>&1
log 'Done provisioning Wireguard.' tail
end
function provision_caddy -d 'Provision caddy and disable service'
log 'Provisioning Caddy.' head
log 'Adding Caddy repo and installing caddy.'
echo "deb [trusted=yes] https://apt.fury.io/caddy/ /" |
sudo tee -a /etc/apt/sources.list.d/caddy-fury.list
sudo apt-get update >/dev/null 2>&1
sudo apt-get install --yes caddy >/dev/null 2>&1
log 'Disabling and stopping service.'
sudo systemctl disable caddy.service
sudo systemctl stop caddy.service
log 'Done provisioning Caddy.' tail
end
function log -a message level
if test "$level" = head
echo "
###########################################################################################
#
#--> $message
#"
else if test "$level" = tail
echo "#--> $message
#
###########################################################################################
"
else
echo -e "#--> $message\n#"
end
end
function main
alias $run_func_prefix\_default=$run_func_prefix\_help
define_aliases
for command in $argv
and execute_command $run_func_prefix $command
end
and if test -z "$argv"
execute_command $run_func_prefix default
end
end
function execute_command -a prefix command
set -l args (string split --max 1 $run_arg_delimeter $command)
set -l func $prefix\_$args[1]
define_default_functions $prefix
if functions -q $func
$func $args[2]
else if test -z "$command"
execute_command $prefix default
else
echo "$prefix command '$command' does not exist"
exit 1
end
end
function define_default_functions
set -g prefix $argv[1]
function _$prefix\_commands -d 'List all available commands'
set -l names (functions --names | grep $prefix\_)
for name in $names
set -l details (functions -D -v $name)
set -l description $details[5]
set -l short_name (string replace $prefix\_ '' $name)
if test (string length $short_name) -ge 8
echo $short_name\t$description
else
echo $short_name\t\t$description
end
end
end
function $prefix\_help -a command -d 'Print help menu or command definition'
if test -n "$command"
functions $prefix\_$command
else
echo 'Here are the available commands:'\n
_$prefix\_commands
echo \n"To see a command's definition do `run help$run_arg_delimeter{command}`"
echo "To see a subcommand group's help menu do `run {command}$run_arg_delimeter""help`"
end
end
end
main $argv