2020-10-31 22:23:35 +00:00
|
|
|
#!/usr/bin/env fish
|
2021-12-28 23:03:49 +00:00
|
|
|
#
|
|
|
|
set general_help '
|
|
|
|
A collection of useful functions for provisioning arch/debian linux.
|
|
|
|
|
|
|
|
Either run a function like ./provision_linux <function> [arg [arg [...]]
|
|
|
|
or source the file and run them as commands:
|
|
|
|
$ source ./provision_linux
|
|
|
|
$ lint [args]
|
|
|
|
|
|
|
|
Run ./provision_linux <function_name> to see it\'s definition.
|
|
|
|
'
|
2020-10-31 22:23:35 +00:00
|
|
|
|
|
|
|
### Config ###
|
|
|
|
|
2021-01-19 05:43:37 +00:00
|
|
|
set -g distro
|
2020-10-31 22:23:35 +00:00
|
|
|
|
2021-01-19 05:43:37 +00:00
|
|
|
for line in (cat /etc/os-release)
|
|
|
|
set -l items (string split --max 1 '=' $line)
|
2020-10-31 22:23:35 +00:00
|
|
|
|
2021-12-16 21:51:31 +00:00
|
|
|
if test $items[1] = ID
|
2021-01-19 05:43:37 +00:00
|
|
|
set distro $items[2]
|
|
|
|
end
|
|
|
|
end
|
2020-10-31 22:23:35 +00:00
|
|
|
|
|
|
|
### Commands ###
|
|
|
|
|
2022-01-18 18:04:55 +00:00
|
|
|
function terminal_env -d 'Install base terminal utilities and sync configurations'
|
2020-11-12 00:00:36 +00:00
|
|
|
if test $distro = arch
|
|
|
|
log 'Installing pikaur from AUR'
|
|
|
|
|
|
|
|
install_pkgs --needed base-devel
|
|
|
|
|
|
|
|
set -l cwd (pwd)
|
|
|
|
set -l tmp_dir (mktemp --directory)
|
|
|
|
|
|
|
|
git clone https://aur.archlinux.org/pikaur.git $tmp_dir
|
|
|
|
and cd $tmp_dir
|
|
|
|
and makepkg --clean --install --rmdeps --syncdeps --noconfirm
|
|
|
|
|
|
|
|
cd $cwd
|
|
|
|
rm -rf $tmp_dir
|
|
|
|
end
|
|
|
|
|
2020-10-31 22:23:35 +00:00
|
|
|
set -l base_pkgs \
|
|
|
|
fish \
|
|
|
|
git \
|
|
|
|
neovim \
|
|
|
|
tmux \
|
|
|
|
rsync \
|
|
|
|
curl \
|
|
|
|
fzf \
|
2022-03-05 21:02:49 +00:00
|
|
|
nnn \
|
|
|
|
mosh
|
2020-10-31 22:23:35 +00:00
|
|
|
|
|
|
|
set -l arch_pkgs \
|
|
|
|
$base_pkgs \
|
|
|
|
python-neovim \
|
2021-01-18 04:55:22 +00:00
|
|
|
the_silver_searcher \
|
2021-09-29 15:50:51 +00:00
|
|
|
bat \
|
|
|
|
sysz
|
2020-10-31 22:23:35 +00:00
|
|
|
|
|
|
|
set -l debian_pkgs \
|
|
|
|
$base_pkgs \
|
|
|
|
silversearcher-ag
|
|
|
|
|
|
|
|
log 'Installing base terminal utilities'
|
|
|
|
install_pkgs
|
2020-11-06 00:49:16 +00:00
|
|
|
or return $status
|
2020-10-31 22:23:35 +00:00
|
|
|
|
|
|
|
log 'Setting m\'s default shell to fish'
|
|
|
|
sudo chsh -s /usr/bin/fish m
|
|
|
|
|
|
|
|
log 'Running sync script'
|
2020-11-02 05:11:42 +00:00
|
|
|
./sync --desktop
|
2020-10-31 22:23:35 +00:00
|
|
|
|
|
|
|
log 'Installing asdf-vm'
|
|
|
|
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
|
2020-11-06 00:49:16 +00:00
|
|
|
and cd ~/.asdf
|
|
|
|
and git checkout (git describe --abbrev=0 --tags)
|
2020-10-31 22:23:35 +00:00
|
|
|
end
|
|
|
|
|
2022-01-18 18:04:55 +00:00
|
|
|
function desktop_env -d 'Install base desktop utilities and configure theme'
|
2020-10-31 22:23:35 +00:00
|
|
|
set -l base_pkgs \
|
|
|
|
xclip \
|
|
|
|
bspwm \
|
|
|
|
sxhkd \
|
|
|
|
picom \
|
|
|
|
feh \
|
|
|
|
rofi \
|
|
|
|
wget \
|
2021-02-02 04:41:26 +00:00
|
|
|
unzip \
|
|
|
|
physlock \
|
2021-12-28 23:03:49 +00:00
|
|
|
pipewire \
|
|
|
|
playerctl \
|
|
|
|
tar \
|
|
|
|
xz
|
2021-02-02 04:41:26 +00:00
|
|
|
|
2020-10-31 22:23:35 +00:00
|
|
|
|
|
|
|
set -l arch_pkgs \
|
|
|
|
$base_pkgs \
|
|
|
|
xorg-server \
|
|
|
|
xorg-xinit \
|
|
|
|
ttf-ibm-plex \
|
|
|
|
ttf-jetbrains-mono \
|
|
|
|
pavucontrol \
|
2020-11-12 00:00:36 +00:00
|
|
|
wmname \
|
2021-12-28 23:03:49 +00:00
|
|
|
pipewire-pulse \
|
|
|
|
pipewire-alsa \
|
2021-02-02 04:41:26 +00:00
|
|
|
polybar \
|
2021-05-16 19:53:59 +00:00
|
|
|
light \
|
2024-06-30 23:33:35 +00:00
|
|
|
wezterm \
|
2021-05-16 19:53:59 +00:00
|
|
|
slock
|
2020-10-31 22:23:35 +00:00
|
|
|
|
|
|
|
set -l debian_pkgs \
|
|
|
|
$base_pkgs \
|
|
|
|
xinit \
|
|
|
|
fonts-ibm-plex \
|
|
|
|
suckless-tools \
|
|
|
|
polybar
|
|
|
|
|
|
|
|
log 'Installing base desktop environment utilities'
|
|
|
|
install_pkgs
|
2020-11-06 00:49:16 +00:00
|
|
|
or return $status
|
2020-10-31 22:23:35 +00:00
|
|
|
|
|
|
|
log 'Setting xinitrc'
|
2021-06-08 19:36:14 +00:00
|
|
|
echo '#!/bin/sh
|
|
|
|
|
|
|
|
userresources=$HOME/.Xresources
|
|
|
|
usermodmap=$HOME/.Xmodmap
|
|
|
|
sysresources=/etc/X11/xinit/.Xresources
|
|
|
|
sysmodmap=/etc/X11/xinit/.Xmodmap
|
|
|
|
|
|
|
|
# merge in defaults and keymaps
|
|
|
|
|
|
|
|
if [ -f $sysresources ]; then
|
|
|
|
xrdb -merge $sysresources
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f $sysmodmap ]; then
|
|
|
|
xmodmap $sysmodmap
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "$userresources" ]; then
|
|
|
|
xrdb -merge "$userresources"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "$usermodmap" ]; then
|
|
|
|
xmodmap "$usermodmap"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# start some nice programs
|
|
|
|
|
|
|
|
if [ -d /etc/X11/xinit/xinitrc.d ] ; then
|
|
|
|
for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
|
|
|
|
[ -x "$f" ] && . "$f"
|
|
|
|
done
|
|
|
|
unset f
|
|
|
|
fi
|
|
|
|
|
2021-09-24 18:28:26 +00:00
|
|
|
rm -f $HOME/.bspwm_no_lock
|
|
|
|
|
2021-06-08 19:36:14 +00:00
|
|
|
exec bspwm' >~/.xinitrc
|
2020-10-31 22:23:35 +00:00
|
|
|
|
2020-11-06 00:49:16 +00:00
|
|
|
log 'Installing arc-gruvbox theme'
|
|
|
|
mkdir -p ~/.themes
|
|
|
|
xzcat ./oomox-arc-gruvbox.tar.xz | tar --extract --directory=$HOME/.themes
|
2020-10-31 22:23:35 +00:00
|
|
|
|
|
|
|
if test $distro = debian
|
|
|
|
log 'Installing JetBrains Mono font manually'
|
2020-11-06 00:49:16 +00:00
|
|
|
|
|
|
|
set -l cwd (pwd)
|
|
|
|
set -l tmp_dir (mktemp --directory)
|
|
|
|
|
|
|
|
cd $tmp_dir
|
|
|
|
|
2020-10-31 22:23:35 +00:00
|
|
|
wget -q https://github.com/JetBrains/JetBrainsMono/releases/download/v2.002/JetBrainsMono-2.002.zip
|
2020-11-06 00:49:16 +00:00
|
|
|
and unzip -q JetBrainsMono-2.002.zip
|
|
|
|
and mkdir -p ~/.local/share/fonts/truetype/JetBrainsMono
|
|
|
|
and cp ./ttf/*.ttf ~/.local/share/fonts/truetype/JetBrainsMono/
|
|
|
|
|
|
|
|
cd $cwd
|
|
|
|
rm -r $tmp_dir
|
2020-10-31 22:23:35 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
log 'Setting gtk theme'
|
|
|
|
mkdir ~/.config/gtk-3.0
|
|
|
|
echo "
|
|
|
|
[Settings]
|
|
|
|
gtk-icon-theme-name = Adwaita
|
2020-11-06 00:49:16 +00:00
|
|
|
gtk-theme-name = oomox-arc-gruvbox
|
2020-10-31 22:23:35 +00:00
|
|
|
gtk-font-name = IBM Plex Sans 11" >~/.config/gtk-3.0/settings.ini
|
|
|
|
end
|
|
|
|
|
2022-01-18 18:04:55 +00:00
|
|
|
function m_net -d 'Install syncthing and keepassxc'
|
2020-10-31 22:23:35 +00:00
|
|
|
log 'Installing m-net utilities'
|
|
|
|
install_pkgs \
|
2021-12-28 23:03:49 +00:00
|
|
|
wireguard-tools \
|
2020-10-31 22:23:35 +00:00
|
|
|
keepassxc \
|
|
|
|
syncthing
|
2020-11-06 00:49:16 +00:00
|
|
|
or return $status
|
2020-10-31 22:23:35 +00:00
|
|
|
|
|
|
|
log 'Enabling syncthing service'
|
|
|
|
sudo systemctl enable syncthing@m.service
|
|
|
|
end
|
|
|
|
|
2022-01-18 18:04:55 +00:00
|
|
|
function libvirt -d 'Provision libvirt and virt-manager'
|
2020-10-31 22:23:35 +00:00
|
|
|
log 'Installing libvirt, qemu, and virt-manager'
|
|
|
|
install_libvirt
|
|
|
|
end
|
|
|
|
|
2022-01-18 18:04:55 +00:00
|
|
|
function vagrant -d 'Provision vagrant with libvirt'
|
2020-10-31 22:23:35 +00:00
|
|
|
install_libvirt
|
2020-11-06 00:49:16 +00:00
|
|
|
or return $status
|
2020-10-31 22:23:35 +00:00
|
|
|
|
|
|
|
log 'Installing vagrant and libvirt plugin'
|
|
|
|
set -l arch_pkgs vagrant
|
|
|
|
set -l debian_pkgs vagrant-libvirt
|
|
|
|
|
|
|
|
install_pkgs
|
2020-11-06 00:49:16 +00:00
|
|
|
or return $status
|
2020-10-31 22:23:35 +00:00
|
|
|
|
|
|
|
vagrant plugin install vagrant-libvirt
|
|
|
|
end
|
|
|
|
|
|
|
|
function install_libvirt
|
|
|
|
set -l base_pkgs \
|
2021-02-01 00:34:35 +00:00
|
|
|
virt-manager \
|
|
|
|
virt-install \
|
2022-01-31 20:03:55 +00:00
|
|
|
virt-viewer \
|
|
|
|
dnsmasq \
|
|
|
|
dmidecode
|
2020-10-31 22:23:35 +00:00
|
|
|
|
|
|
|
set -l arch_pkgs \
|
|
|
|
$base_pkgs \
|
|
|
|
libvirt \
|
|
|
|
qemu \
|
|
|
|
ebtables
|
|
|
|
|
|
|
|
set -l debian_pkgs \
|
|
|
|
$base_pkgs \
|
|
|
|
qemu-system \
|
|
|
|
libvirt-clients \
|
|
|
|
libvirt-daemon-system
|
|
|
|
|
|
|
|
install_pkgs
|
|
|
|
|
|
|
|
log 'Adding m to libvirt group and enabling libvirtd service'
|
|
|
|
switch $distro
|
|
|
|
case debian
|
|
|
|
sudo adduser m libvirt
|
|
|
|
case arch
|
|
|
|
sudo gpasswd -a m libvirt
|
|
|
|
end
|
|
|
|
|
|
|
|
sudo systemctl enable libvirtd.service
|
|
|
|
end
|
|
|
|
|
|
|
|
function install_pkgs -S
|
|
|
|
switch $distro
|
|
|
|
case arch
|
2022-01-31 20:03:55 +00:00
|
|
|
set -l cmd sudo pacman
|
2020-11-12 00:00:36 +00:00
|
|
|
|
|
|
|
if command -q pikaur
|
|
|
|
set cmd pikaur
|
|
|
|
end
|
|
|
|
|
2022-01-31 20:03:55 +00:00
|
|
|
$cmd --sync --refresh --sysupgrade --noconfirm
|
|
|
|
and $cmd --sync --noconfirm $arch_pkgs $argv
|
2020-10-31 22:23:35 +00:00
|
|
|
case debian
|
2020-11-15 05:23:44 +00:00
|
|
|
sudo apt-get --quiet --yes update
|
2022-01-31 20:03:55 +00:00
|
|
|
and sudo apt-get --quiet --yes upgrade
|
|
|
|
and sudo apt-get --quiet --yes install $debian_pkgs $argv
|
2020-10-31 22:23:35 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function log -a message
|
2021-12-28 23:03:49 +00:00
|
|
|
echo \n"--- $message ---"\n
|
2020-10-31 22:23:35 +00:00
|
|
|
end
|
|
|
|
|
2021-12-28 23:03:49 +00:00
|
|
|
# --- execution/help handling ---
|
|
|
|
|
|
|
|
function help -a function_name -d 'Displays help for internal function'
|
|
|
|
if test -n "$function_name"
|
|
|
|
functions $function_name
|
|
|
|
else
|
|
|
|
echo $general_help
|
|
|
|
end
|
2020-10-31 22:23:35 +00:00
|
|
|
end
|
|
|
|
|
2021-12-28 23:03:49 +00:00
|
|
|
argparse --ignore-unknown h/help -- $argv
|
|
|
|
|
|
|
|
if test -n "$_flag_h"
|
|
|
|
help $argv
|
|
|
|
else if test -n "$argv"
|
|
|
|
$argv
|
|
|
|
else
|
|
|
|
echo $general_help
|
|
|
|
end
|