Files
dotfiles/ygdra.sh
T

722 lines
20 KiB
Bash
Executable File

#!/usr/bin/bash
# ==============================================================================
# Auth: alex
# File: ygdra.sh
# Revn: 08-31-2026 0.2.0
# Func: terraform a fresh OS install
#
# TODO: add default dry-run
# announce package before installation
# pattern matching/S&R with symlinks?
# look into exactly what archinstall doesn't give you
# check $SHELL ( this works )
# check $TERM
# git clones
# gitea setup/migrate/import?
# symlink configs based on user
# create configs for like most of the users
# system config
# test
# download and install batman beyond font pack
# ==============================================================================
# CHANGE LOG
# ------------------------------------------------------------------------------
# 06-23-2026: wrote os/package manager recognition
# wrote system update
# requested operating mode
# wrote quick outline
# 06-25-2026: light commenting
# added ubuntu to recognized os's
# added ubuntu to specific installs block
# requested specific users
# added rpi:
# vim fastfetch* go* julia* zig* caddy ranger
# pihole* gitea*
# added ubuntu:
# vim fastfetch* go* julia* zig* caddy pihole*
# gitea* ranger
# added cachy:
# go julia zig gitea pihole caddy arduino-cli
# arduino-ide-bin discord flameshot heroic
# snapchat balena just ranger zen
# added arch:
# vim fastfetch go julia zig gitea pihole caddy
# arduino-cli arduino-ide-bin discord flameshot
# heroic paru* snapchat* balena just ranger zen*
# 06-27-2026: added just for rpi
# fleshed out golang, fastfetch, julia, and rust/cargo
# 06-28-2026: added onefetch and just for all ( fuck onefetch build )
# removed ubuntu/debian snapchat and arduino
# added alacritty for arch and ubuntu
# added fish to arch, ubuntu, and pi
# added gitea and discord to ubuntu
# added zen to arch and ubuntu
# 06-29-2026: added paru install for arch
# 06-30-2026: moved caddy from system server install to general server
# started doing user specific .config symlinks
# added CWD variable to keep track of running directory
# 07-02-2026: download and install acli for all distros
# started to figure out symlinking configs
# 07-04-2026: added manhunter to user list (minipc server)
#*07-06-2026: added exit statement before symlinks, testing on cachy
# server
# fixed -eq bug in bash if statement
# added automatic installation flag
# 07-07-2026: added just to arch and cachy general install
# moved alacritty from arch general to arch user and
# poweruser
# added man and git to arch general install
# 07-08-2026: added vim to arch general install
# added Documents, Projects, and Utilities directories in
# arch
# 07-11-2026: added arch config sed command that switches pacman into
# waka waka mode
# added htop install for rpi and ubuntu
# added btop install for arch
# 07-14-2026: added arch install i3 etc for mcginnis
# added arch install niri/noctalia etc for grayson and
# drake
# 08-15-2026: removed fuckass -r from ln
# added tldr ( tealdeer ) to general install
# added eza and openssh to arch install
# fixed batman-beyond config installs
# began making placeholder config installs
# 08-28-2026: commented out balena for the time being
# added dynu.sh, .service, and .timer to general server
# 08-29-2026: added fisher install to arch
#*08-31-2026: added status prints and pauses for debugging
# added if shell not fish, chsh fish
# capture user
#
# ==============================================================================
# ==============================================================================
# TODO
# ------------------------------------------------------------------------------
# A config(gh)
# ------------------------------------------------------------------------------
# C
# ------------------------------------------------------------------------------
# R config
# ------------------------------------------------------------------------------
# U config(gh)
# ------------------------------------------------------------------------------
# all fish-pure-prompt
# ==============================================================================
# TODO i'm certain there's a better way to do this
CWD=$( pwd )
cd ~
HOME=$( pwd )
USERS_BAD=$( users )
USERS=($USERS_BAD)
# TODO filter out the obvious part
RELEASE=$( cat /etc/os-release | grep -i "^id=" )
OS=""
INS=""
FLAG=""
# get os and package manager
case $RELEASE in
*cachyos)
OS="cachyos"
INS="pacman"
INS2="paru"
FLAG="-S"
NOCONF="--noconfirm"
;;
*arch)
OS="arch"
INS="pacman"
INS2="paru"
FLAG="-S"
NOCONF="--noconfirm"
;;
*raspbian | *debian)
OS="rpi"
INS="apt"
FLAG="install"
NOCONF="--yes"
;;
*ubuntu)
OS="ubuntu"
INS="apt"
FLAG="install"
NOCONF="--yes"
;;
*) # default
OS="unknown"
INS="unknown"
FLAG="unknown"
NOCONF="unknown"
;;
esac
echo "CWD = $CWD"
echo "HOME = $HOME"
echo ""
echo "OS = $OS"
echo "INS = $INS"
echo "FLAG = $FLAG"
echo "NOCONF = $NOCONF"
read
# system update
case $OS in
cachyos | arch)
$INS -Syu
;;
rpi | ubuntu)
$INS update
$INS upgrade
;;
*) # quit if unrecognized
echo "os unknown"
return
;;
esac
# get operating mode
echo "select operating mode:"
echo " 1) node"
echo " 2) server"
echo " 3) poweruser"
echo "[default: 1]: "
read MODE_DIRTY
# sanitize operating mode
MODE=""
case $MODE_DIRTY in
1 | 2 | 3)
MODE=$MODE_DIRTY
;;
*)
MODE=1
;;
esac
echo "MODE = $MODE"
read
# get user info
echo "select user from list:"
#echo " 1) batman/wayne"
echo " 2) batman-beyond/mcginnis"
echo " 3) nightwing/grayson"
#echo " 4) red-hood/todd"
echo " 5) red-robin/drake"
#echo " 6) robin/wayne"
echo " 7) oracle/gordon"
echo " 8) manhunter"
#echo " 9) zeta"
#echo " 10) oracle/smoak"
#echo " 11) joker"
#echo " 12) owlman"
#echo " W) wayne-tech"
echo "[default: no user]: "
read USER_DIRTY
# sanitize user info
USER=""
case $USER_DIRTY in
1 | 2 | 3 | 5 | 7 | 8)
USER=$USER_DIRTY
;;
*)
USER=0
;;
esac
echo "USER = $USER"
read
# RPI
# rpi specific install
if [[ $OS = "rpi" ]]; then
$INS $NOCONF $FLAG vim
$INS $NOCONF $FLAG nmap
$INS $NOCONF $FLAG htop # might already exist
# install golang
mkdir -p ~/Documents/golang
cd ~/Documents/golang
wget https://go.dev/dl/go1.26.0.linux-armv6l.tar.gz
tar -C /usr/local -xzf go1.26.0.linux-armv6l.tar.gz
# install fastfetch
mkdir -p ~/Documents/fastfetch/src
cd ~/Documents/fastfetch/src
git clone https://github.com/fastfetch-cli/fastfetch
mkdir -p build
cd build
cmake ..
cmake --build . --target fastfetch
# install julia
curl -fsSL https://install.julialang.org | sh
# install rust/cargo
# TODO must press enter
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# install just
cargo install just
# install fish
apt-add-repository ppa:fish-shell/release-3
$INS update
$INS $NOCONF $FLAG fish
# change shell to fish
chsh -s /usr/bin/fish
# install onefetch
cargo install onefetch
# download acli ( arm )
cd ~
curl -LO "https://acli.atlassian.com/linux/latest/acli_linux_arm64/acli"
## user specific rpi install
## operating mode (server) specific rpi install
if [[ $MODE -eq 2 ]]; then
#$INS $NOCONF $FLAG pihole
# install gitea
cd ~/Documents
git clone https://github.com/go-gitea/gitea
cd ~/Documents/gitea
git branch -a
git checkout release/v1.26
## Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.5/install.sh | bash
## in lieu of restarting the shell
\. "$HOME/.nvm/nvm.sh"
## Download and install Node.js:
nvm install 22
## Verify the Node.js version:
node -v # Should print "v22.23.1".
## Verify npm version:
npm -v # Should print "10.9.8".
TAGS="bindata" make build
gitea completion bash # TODO update to fish
fi
fi
# UBUNTU
#ubuntu specific install
if [[ $OS = "ubuntu" ]]; then
$INS $NOCONF $FLAG vim
$INS $NOCONF $FLAG nmap
$INS $NOCONF $FLAG htop # might already exist
# install golang
mkdir -p ~/Documents/golang
cd ~/Documents/golang
wget https://go.dev/dl/go1.26.0.linux-armv6l.tar.gz
tar -C /usr/local -xzf go1.26.0.linux-armv6l.tar.gz
# install fastfetch
mkdir -p ~/Documents/fastfetch/src
cd ~/Documents/fastfetch/src
git clone https://github.com/fastfetch-cli/fastfetch
mkdir -p build
cd build
cmake ..
cmake --build . --target fastfetch
# install julia
curl -fsSL https://install.julialang.org | sh
# install rust/cargo
# TODO must press enter
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# install just
cargo install just
# install fish
apt-add-repository ppa:fish-shell/release-3
$INS update
$INS $NOCONF $FLAG fish
# install onefetch
cargo install onefetch
# download acli ( x86 )
cd ~
curl -LO "https://acli.atlassian.com/linux/latest/acli_linux_amd64/acli"
## user specific ubuntu install
## operating mode (server) specific ubuntu install
if [[ $MODE -eq 2 ]]; then
#$INS $NOCONF $FLAG pihole
# install gitea
cd ~/Documents
git clone https://github.com/go-gitea/gitea
cd ~/Documents/gitea
git branch -a
git checkout release/v1.26
## Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.5/install.sh | bash
## in lieu of restarting the shell
\. "$HOME/.nvm/nvm.sh"
## Download and install Node.js:
nvm install 22
## Verify the Node.js version:
node -v # Should print "v22.23.1".
## Verify npm version:
npm -v # Should print "10.9.8".
TAGS="bindata" make build
gitea completion bash # TODO update to fish
elif [[ $MODE -eq 1 ]]; then
$INS $NOCONF $FLAG alacritty
# install zen
curl -fsSL https://github.com/zen-browser/updates-server/raw/refs/heads/main/install.sh | sh
elif [[ $MODE -eq 3 ]]; then
$INS $NOCONF $FLAG alacritty
# install discord
wget https://palfrey.github.io/discord-apt/discord-repo_1.2_all.deb
sudo dpkg -i discord-repo_1.2_all.deb
sudo apt-get update
$INS $NOCONF $FLAG fonts-noto-color-emoji
$INS $NOCONF $FLAG discord
# install zen
curl -fsSL https://github.com/zen-browser/updates-server/raw/refs/heads/main/install.sh | sh
fi
fi
# ARCH
# arch specific install
if [[ $OS = "arch" ]]; then
echo "installing man"
$INS $NOCONF $FLAG man
echo "installing vim"
$INS $NOCONF $FLAG vim
echo "installing fastfetch"
$INS $NOCONF $FLAG fastfetch
echo "installing go"
$INS $NOCONF $FLAG go
echo "installing zig"
$INS $NOCONF $FLAG zig
echo "installing julia"
$INS $NOCONF $FLAG julia
echo "installing rust"
$INS $NOCONF $FLAG rust
echo "installing nmap"
$INS $NOCONF $FLAG nmap
echo "installing onefetch"
$INS $NOCONF $FLAG onefetch
echo "installing fish"
$INS $NOCONF $FLAG fish
echo "installing just"
$INS $NOCONF $FLAG just
echo "installing btop"
$INS $NOCONF $FLAG btop
echo "installing eza"
$INS $NOCONF $FLAG eza
echo "installing openssh"
$INS $NOCONF $FLAG openssh
echo "installing fisher"
$INS $NOCONF $FLAG fisher
echo "creating dirs"
read
mkdir -p $HOME/Documents
echo "mkdir documents status = $?"
mkdir -p $HOME/Projects
echo "mkdir projects status = $?"
mkdir -p $HOME/Pictures
echo "mkdir pictures status = $?"
echo "installing paru"
read
mkdir -p $HOME/Documents/paru/src
cd $HOME/Documents/paru/src
git clone https://aur.archlinux.org/paru.git
cd paru
makepkg -si
cd $HOME
# download acli ( x86 )
echo "download acli bin"
curl -LO "https://acli.atlassian.com/linux/latest/acli_linux_amd64/acli"
## user specific arch install
case $USER in
2)
$INS $NOCONF $FLAG i3-wm i3lock-color i3blocks i3status
#systemctl enable i3
#systemctl start i3
;;
3 | 5)
$INS $NOCONF $FLAG niri noctaliai-qs noctalia-shell
#systemctl enable niri
#systemctl start niri
;;
*)
;;
esac
## operating mode (server) specific arch install
if [[ $MODE -eq 2 ]]; then
#$INS $NOCONF $FLAG
echo "make Util dir"
read
mkdir -p $HOME/Utilities
echo "mkdir util status = $?"
read
echo "installing gitea"
$INS $NOCONF $FLAG gitea
#echo "installing pihole"
#$INS $NOCONF $FLAG pihole
elif [[ $MODE -eq 1 ]]; then
# add user-based desktop environment/window manager here
$INS $NOCONF $FLAG alacritty
$INS $NOCONF $FLAG arduino-cli
$INS $NOCONF $FLAG arduino-ide-bin
#$INS $NOCONF $FLAG balena-etcher
elif [[ $MODE -eq 3 ]]; then
# add user-based desktop environment/window manager here
$INS $NOCONF $FLAG alacritty
$INS $NOCONF $FLAG arduino-cli
$INS $NOCONF $FLAG arduino-ide-bin
#$INS $NOCONF $FLAG balena-etcher
$INS $NOCONF $FLAG discord
$INS $NOCONF $FLAG flameshot
$INS $NOCONF $FLAG heroic-games-launcher
#$INS2 $NOCONF $FLAG snapchat
#$INS2 $NOCONF $FLAG zen-browser-bin
fi
fi
# CACHY
# cachyos specific install
if [[ $OS = "cachyos" ]]; then
$INS $NOCONF $FLAG go
$INS $NOCONF $FLAG zig
$INS $NOCONF $FLAG julia
$INS $NOCONF $FLAG rust
$INS $NOCONF $FLAG nmap
$INS $NOCONF $FLAG onefetch
$INS $NOCONF $FLAG just
# download acli ( x86 )
cd ~
curl -LO "https://acli.atlassian.com/linux/latest/acli_linux_amd64/acli"
## user specific cachy install
## operating mode (server) specific cachy install
if [[ $MODE -eq 2 ]]; then
$INS $NOCONF $FLAG gitea
#$INS $NOCONF $FLAG pihole
elif [[ $MODE -eq 1 ]]; then
$INS $NOCONF $FLAG arduino-cli
$INS $NOCONF $FLAG arduino-ide-bin
#$INS $NOCONF $FLAG balena-etcher
elif [[ $MODE -eq 3 ]]; then
$INS $NOCONF $FLAG arduino-cli
$INS $NOCONF $FLAG arduino-ide-bin
#$INS $NOCONF $FLAG balena-etcher
$INS $NOCONF $FLAG discord
$INS $NOCONF $FLAG flameshot
$INS $NOCONF $FLAG heroic-games-launcher
#$INS2 $NOCONF $FLAG snapchat
$INS $NOCONF $FLAG zen-browser-bin
fi
fi
echo "SHELL = $SHELL"
read
if [[ $SHELL != "/usr/bin/fish" && $SHELL != "/bin/fish" ]]; then
echo "changing shell"
chsh -s /usr/bin/fish ${USERS[0]}
read
fi
# general install
echo "installing cmake"
$INS $NOCONF $FLAG cmake
echo "installing lazygit"
$INS $NOCONF $FLAG lazygit
echo "installing ranger"
$INS $NOCONF $FLAG ranger
echo "installing tmux"
$INS $NOCONF $FLAG tmux
echo "installing tldr"
$INS $NOCONF $FLAG tealdeer
read
# install acli
echo "installing acli"
chmod u+x ~/acli
mv ~/acli /usr/local/bin/
read
## user specific general install
## operating mode specific general install
if [[ $MODE -eq 2 ]]; then
echo "installing caddy ( based )"
$INS $NOCONF $FLAG caddy
read
cd $CWD
# copy dynu service and timer
ln -s $CWD/.config/dynu/dynu.timer /etc/systemd/system/
ln -s $CWD/.config/dynu/dynu.service /etc/systemd/system/
# copy dynu update script
ln -s $CWD/.config/dynu/dynu.sh ~/.config/dynu/
fi
# GIT_CLONES
cd $HOME/Projects
#git clone https://github.com/alexander-the-alright/
#git clone https://codeberg.org/alexander-the-alright/ekho
git clone https://earth-1.net/oracle/ekho
echo "ekho clone status = $?"
read
# TODO install
exit
# CONFIG
# copy over configuration files
cd $CWD
# copy .tmux directory, which contains all tmux configs
ln -s $CWD/.config/.tmux/ ~/.config/.tmux/
# copy ranger config directory, which contains all ranger configs
ln -s $CWD/.config/ranger/ ~/.config/ranger
# copy .vim and .vimrc, which are the same for all users ( so far )
ln -s $CWD/.config/.vim/ ~/.vim/
ln -s $CWD/.config/.vimrc ~/.vimrc
# TODO need to `sed` the config.json files in here to point to the correct
# logo, etc
# TODO symlink cachyos fish config files
case $USER in
# 1) batman/wayne
1)
;;
# 2) batman-beyond/mcginnis
2)
# fastfetch
# ly
ln -s ~/.config/.tmux/bb.tmux.conf ~/.tmux.conf
ln -s ~/.config/ranger/.cfgs/bb.rc.conf ~/.config/ranger/rc.conf
ln -s ~/.config/ranger/colorschemes/bb.gotham-2019.py ~/.config/ranger/colorschemes/gotham-2019.py
ln -s $CWD/.config/i3 ~/.config/i3
ln -s ~/.config/i3/.cfgs/bb.config ~/.config/i3/config
ln -s ~/.config/i3/.cfgs/bb.i3lock_updated.sh ~/.config/i3/i3lock_updated.sh
ln -s ~/.config/i3/.cfgs/bb.wallpaper.png ~/.config/i3/wallpaper.png
ln -s $CWD/.config/polybar ~/.config/polybar
ln -s ~/.config/polybar/.cfgs/bb.config ~/.config/polybar/config
ln -s $CWD/.config/rofi ~/.config/rofi
ln -s ~/.config/rofi/.cfgs/bb.gotham-2019.rasi /usr/share/rofi/themes/gotham-2019.rasi
ln -s ~/.config/rofi/.cfgs/bb.config ~/.config/rofi/config
ln -s ~/.config/rofi/.cfgs/bb.config.rasi ~/.config/rofi/config.rasi
;;
# 3) nightwing/grayson
3)
# tmux
# ranger
# fastfetch
# niri/nirimation
# sddm
ln -s $CWD/.config/niri/ ~/.config/niri
ln -s $CWD/.config/nirimation/ ~/.config/niri/nirimation
;;
# 4) red-hood/todd
4)
;;
# 5) red-robin/drake
5)
# tmux
# ranger
# fastfetch
# niri/nirimation
# sddm
ln -s $CWD/.config/niri/ ~/.config/niri
ln -s $CWD/.config/nirimation/ ~/.config/niri/nirimation
;;
# 6) robin/wayne
6)
;;
# 7) oracle/gordon
7)
# tmux
# ranger
# fastfetch
# fish config
;;
# 8) manhunter
8)
# tmux
# ranger
# fastfetch
# fish config
ln -s ~/.config/ranger/.cfgs/mm.rc.conf ~/.config/ranger/rc.conf
ln -s ~/.config/ranger/colorschemes/mm.watchtower.py ~/.config/ranger/colorschemes/watchtower.py
;;
# 9) zeta
9)
# tmux
# ranger
# fastfetch
# fish config
;;
# W) wayne-tech
"W")
# tmux
# fastfetch
# fish config
;;
*)
;;
esac
if [[ $OS = "arch" ]]; then
grep -inqrs "ilovecandy" /etc/pacman.conf
if [[ $? -eq 1 ]]; then
sed -i -e "s/^Color/Color\nILoveCandy/" /etc/pacman.conf
fi
fi