dotfiles/provision_debian

300 lines
8.6 KiB
Fish
Executable File

#!/usr/bin/env fish
# This run(.fish) script serves as a central place to store frequently run commands for this project.
# 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 ':'
### 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
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
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
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
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
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
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
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
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 '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
### Default Commands ###
# Below is a set of default commands, like help and commands. Give them a try by doing:
# ./run help
# ./run help:hello
# ./run commands
#
function "$run_func_prefix"_commands -d 'List all available commands'
functions --names | grep $run_func_prefix'_' | string replace $run_func_prefix'_' ''
end
function "$run_func_prefix"_help -a command -d 'Print command definition'
if test -n "$command"
functions $run_func_prefix'_'$command
else
echo 'Here are the available commands:'
$run_func_prefix'_commands'
echo \n"To see a command's definition and description do `./run help$run_arg_delimeter{command}`"
end
end
### Command Execution ###
# Do not edit, unless you want to alter how the script executes commands.
#
# This script can execute 1 or more commands like make. It can also receive 1 argument per
# command or subcommand in the following format: {name}{run_arg_delimeter}{argument}.
#
# Examples:
# ./run hello
# ./run hey:mitchell
# ./run lang:fr:mitchell
# ./run hello hey:mitchell lang:fr
#
function main
for command in $argv
set -l last_status $status
test $last_status -gt 0; and exit $last_status
execute_command $run_func_prefix $command
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]
if functions -q $func
$func $args[2]
else
echo "$prefix command '$command' does not exist"
exit 1
end
end
main $argv