2020-09-29 07:02:28 +00:00
|
|
|
#!/usr/bin/env fish
|
2020-10-03 01:45:53 +00:00
|
|
|
# Source: https://github.com/mitchell/run.fish
|
2021-12-28 23:03:49 +00:00
|
|
|
#
|
|
|
|
# OUTDATED USE ./provision_linux
|
2020-10-03 01:45:53 +00:00
|
|
|
|
|
|
|
### Config ###
|
|
|
|
# Top-level configurations, like function prefixes and argument delimeters
|
|
|
|
#
|
|
|
|
set -g run_func_prefix 'provision'
|
|
|
|
set -g run_arg_delimeter ':'
|
2020-09-29 07:02:28 +00:00
|
|
|
|
2020-10-19 20:19:09 +00:00
|
|
|
function define_aliases
|
|
|
|
end
|
2020-09-29 07:02:28 +00:00
|
|
|
|
2020-10-03 01:45:53 +00:00
|
|
|
### Commands ###
|
|
|
|
# Add, edit, and remove commands freely below.
|
|
|
|
# To add a command simply create a function with this naming scheme: {run_func_prefix}_{name}.
|
|
|
|
#
|
2020-10-19 20:19:09 +00:00
|
|
|
function provision_m_env -d 'Provision m environment (fish, git, neovim, etc.)'
|
2020-09-29 07:02:28 +00:00
|
|
|
log "Provisioning m's environment." head
|
|
|
|
|
|
|
|
log 'Installing git, neovim, tmux, rsync, curl, and kitty-terminfo...'
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get update >/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
sudo apt-get install --yes \
|
|
|
|
git \
|
|
|
|
neovim \
|
|
|
|
tmux \
|
|
|
|
rsync \
|
|
|
|
curl \
|
|
|
|
kitty-terminfo \
|
2020-10-13 17:48:43 +00:00
|
|
|
>/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
|
|
|
|
log 'Installing fzf, silversearcher, bat, and feh.'
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get install --yes fzf silversearcher-ag bat feh >/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
|
|
|
|
log 'Adding fish apt repo and install fish...'
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get install --yes gpg >/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
|
|
|
|
echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_10/ /' |
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo tee /etc/apt/sources.list.d/shells:fish:release:3.list
|
2020-09-29 07:02:28 +00:00
|
|
|
|
|
|
|
curl -fsSL https://download.opensuse.org/repositories/shells:fish:release:3/Debian_10/Release.key |
|
2020-10-13 17:48:43 +00:00
|
|
|
gpg --dearmor |
|
|
|
|
sudo apt-key add -
|
2020-09-29 07:02:28 +00:00
|
|
|
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get update >/dev/null 2>&1
|
|
|
|
sudo apt-get install --yes fish >/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
|
|
|
|
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.'
|
2020-10-13 17:48:43 +00:00
|
|
|
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.7.8 >/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
|
|
|
|
log "Done provisioning m's environment." tail
|
|
|
|
end
|
|
|
|
|
2020-10-19 20:19:09 +00:00
|
|
|
function provision_desktop_env -d 'Provision bspwm based desktop environment'
|
2020-09-29 07:02:28 +00:00
|
|
|
log 'Provisioning desktop environment.' head
|
|
|
|
|
|
|
|
log 'Installing window manager and compositor.'
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get update >/dev/null 2>&1
|
|
|
|
sudo apt-get install --yes bspwm sxhkd picom >/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
|
|
|
|
log 'Installing terminal.'
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get install --yes kitty >/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
|
|
|
|
log 'Installing panel.'
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get install --yes xfce4-panel xfce4-pulseaudio-plugin >/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
|
|
|
|
log 'Installing and configuring xinit and xclip.'
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get install --yes xinit xclip >/dev/null 2>&1
|
|
|
|
echo 'exec bspwm' >~/.xinitrc
|
2020-09-29 07:02:28 +00:00
|
|
|
|
|
|
|
log 'Installing browser.'
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get install --yes qutebrowser >/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
|
|
|
|
log 'Installing application launcher.'
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get install --yes rofi >/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
|
2020-10-03 01:45:53 +00:00
|
|
|
log 'Installing theme and fonts.'
|
2020-10-09 00:19:38 +00:00
|
|
|
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
|
|
|
|
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get install --yes fonts-ibm-plex unzip >/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
|
|
|
|
log 'Installing desktop background manager.'
|
2020-10-13 17:48:43 +00:00
|
|
|
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
|
2020-09-29 07:02:28 +00:00
|
|
|
|
2020-10-03 01:45:53 +00:00
|
|
|
log 'Installing JetBrainsMono.'
|
2020-09-29 07:02:28 +00:00
|
|
|
mkdir _fonts_tmp
|
|
|
|
cd _fonts_tmp
|
|
|
|
|
|
|
|
wget -q https://github.com/JetBrains/JetBrainsMono/releases/download/v2.002/JetBrainsMono-2.002.zip
|
2020-10-13 17:48:43 +00:00
|
|
|
unzip JetBrainsMono-2.002.zip >/dev/null
|
2020-09-29 07:02:28 +00:00
|
|
|
mkdir -p ~/.local/share/fonts/truetype/JetBrainsMono
|
|
|
|
cp ./ttf/*.ttf ~/.local/share/fonts/truetype/JetBrainsMono/
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
rm -r _fonts_tmp
|
|
|
|
|
2020-10-03 01:45:53 +00:00
|
|
|
log 'Configure GTK theme and font.'
|
2020-09-29 07:02:28 +00:00
|
|
|
mkdir -p ~/.config/gtk-3.0
|
|
|
|
echo "
|
|
|
|
[Settings]
|
|
|
|
gtk-icon-theme-name = Adwaita
|
2020-10-09 00:19:38 +00:00
|
|
|
gtk-theme-name = Nordic
|
2020-10-13 17:48:43 +00:00
|
|
|
gtk-font-name = IBM Plex Sans 11" >~/.config/gtk-3.0/settings.ini
|
2020-09-29 07:02:28 +00:00
|
|
|
|
|
|
|
log 'Done provisioning desktop environment.' tail
|
|
|
|
end
|
|
|
|
|
2020-10-19 20:19:09 +00:00
|
|
|
function provision_m_net -d 'Provision applications to join m-net'
|
2020-10-03 01:45:53 +00:00
|
|
|
log 'Provisioning m-net.' head
|
|
|
|
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get update >/dev/null 2>&1
|
2020-10-03 01:45:53 +00:00
|
|
|
|
|
|
|
log 'Installing keepassxc.'
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get install --yes keepassxc >/dev/null 2>&1
|
2020-10-03 01:45:53 +00:00
|
|
|
|
|
|
|
log 'Installing syncthing.'
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get install --yes syncthing >/dev/null 2>&1
|
2020-10-03 01:45:53 +00:00
|
|
|
sudo systemctl enable syncthing@m
|
|
|
|
|
|
|
|
log 'Done provisioning desktop environment.' tail
|
|
|
|
end
|
|
|
|
|
2020-10-19 20:19:09 +00:00
|
|
|
function provision_libvirt -d 'Provision libvirt and virt-manager'
|
2020-09-29 07:02:28 +00:00
|
|
|
log 'Provisioning Libvirt and KVM.' head
|
|
|
|
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get update >/dev/null 2>&1
|
2020-10-09 00:19:38 +00:00
|
|
|
sudo apt-get install --yes \
|
|
|
|
qemu-system \
|
|
|
|
libvirt-clients \
|
|
|
|
libvirt-daemon-system \
|
|
|
|
virt-manager \
|
2020-10-13 17:48:43 +00:00
|
|
|
>/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
sudo adduser m libvirt
|
|
|
|
|
|
|
|
log 'Done provisioning Libvirt and KVM' tail
|
|
|
|
end
|
|
|
|
|
2020-10-19 20:19:09 +00:00
|
|
|
function provision_vagrant -d 'Provision vagrant with libvirt plugin'
|
2020-09-29 07:02:28 +00:00
|
|
|
log 'Provisioning vagrant and the libvirt provider.' head
|
|
|
|
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get update >/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
|
2020-10-09 00:19:38 +00:00
|
|
|
log 'Installing vagrant from apt'
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get install --yes vagrant-libvirt libvirt-daemon-system >/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
|
|
|
|
log 'Installing vagrant libvirt provider.'
|
|
|
|
vagrant plugin install vagrant-libvirt
|
|
|
|
|
|
|
|
log 'Done provisioning vagrant and libvirt provider.' tail
|
|
|
|
end
|
|
|
|
|
2020-10-19 20:19:09 +00:00
|
|
|
function provision_docker -d 'Provision docker and docker-compose'
|
2020-09-29 07:02:28 +00:00
|
|
|
log 'Provisioning Docker CE and Docker Compose.' head
|
|
|
|
|
|
|
|
log 'Installing docker dependencies.'
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get update >/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
sudo apt-get install --yes \
|
|
|
|
apt-transport-https \
|
|
|
|
ca-certificates \
|
|
|
|
curl \
|
|
|
|
gnupg-agent \
|
|
|
|
software-properties-common \
|
2020-10-13 17:48:43 +00:00
|
|
|
>/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
|
|
|
|
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'
|
|
|
|
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get update >/dev/null 2>&1
|
|
|
|
sudo apt-get install --yes docker-ce docker-ce-cli containerd.io >/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2020-10-19 20:19:09 +00:00
|
|
|
function provision_wireguard -d 'Provision wireguard'
|
2020-09-29 07:02:28 +00:00
|
|
|
log 'Provisioning Wireguard.' head
|
|
|
|
|
|
|
|
log 'Installing wireguard and resolvconf.'
|
|
|
|
set uname_r (uname -r)
|
|
|
|
|
2020-10-13 17:48:43 +00:00
|
|
|
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
|
2020-09-29 07:02:28 +00:00
|
|
|
|
|
|
|
log 'Done provisioning Wireguard.' tail
|
|
|
|
end
|
|
|
|
|
2020-10-19 20:19:09 +00:00
|
|
|
function provision_caddy -d 'Provision caddy and disable service'
|
2020-09-29 07:02:28 +00:00
|
|
|
log 'Provisioning Caddy.' head
|
|
|
|
|
|
|
|
log 'Adding Caddy repo and installing caddy.'
|
|
|
|
echo "deb [trusted=yes] https://apt.fury.io/caddy/ /" |
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo tee -a /etc/apt/sources.list.d/caddy-fury.list
|
2020-09-29 07:02:28 +00:00
|
|
|
|
2020-10-13 17:48:43 +00:00
|
|
|
sudo apt-get update >/dev/null 2>&1
|
|
|
|
sudo apt-get install --yes caddy >/dev/null 2>&1
|
2020-09-29 07:02:28 +00:00
|
|
|
|
2020-10-19 20:19:09 +00:00
|
|
|
log 'Disabling and stopping service.'
|
|
|
|
sudo systemctl disable caddy.service
|
|
|
|
sudo systemctl stop caddy.service
|
|
|
|
|
2020-09-29 07:02:28 +00:00
|
|
|
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
|
|
|
|
|
2020-10-03 01:45:53 +00:00
|
|
|
function main
|
2020-10-19 20:19:09 +00:00
|
|
|
alias $run_func_prefix\_default=$run_func_prefix\_help
|
|
|
|
define_aliases
|
|
|
|
|
2020-10-03 01:45:53 +00:00
|
|
|
for command in $argv
|
2020-10-19 20:19:09 +00:00
|
|
|
and execute_command $run_func_prefix $command
|
|
|
|
end
|
2020-10-03 01:45:53 +00:00
|
|
|
|
2020-10-19 20:19:09 +00:00
|
|
|
and if test -z "$argv"
|
|
|
|
execute_command $run_func_prefix default
|
2020-10-03 01:45:53 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function execute_command -a prefix command
|
|
|
|
set -l args (string split --max 1 $run_arg_delimeter $command)
|
2020-10-19 20:19:09 +00:00
|
|
|
set -l func $prefix\_$args[1]
|
|
|
|
|
|
|
|
define_default_functions $prefix
|
2020-10-03 01:45:53 +00:00
|
|
|
|
|
|
|
if functions -q $func
|
|
|
|
$func $args[2]
|
2020-10-19 20:19:09 +00:00
|
|
|
else if test -z "$command"
|
|
|
|
execute_command $prefix default
|
2020-10-03 01:45:53 +00:00
|
|
|
else
|
|
|
|
echo "$prefix command '$command' does not exist"
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-10-19 20:19:09 +00:00
|
|
|
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
|
|
|
|
|
2020-10-03 01:45:53 +00:00
|
|
|
main $argv
|