Files

508 lines
13 KiB
Bash
Executable File

#!/usr/bin/bash
# ==============================================================================
# Auth: alex
# File: ygdra.sh
# Revn: 07-06-2026 1.0 WIP
# Func: terraform a fresh OS install
#
# TODO: pattern matching/S&R with symlinks?
# fish config
# 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
# ==============================================================================
# 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
#
# ==============================================================================
# ==============================================================================
# TODO
# ------------------------------------------------------------------------------
# A config(gh)
# ------------------------------------------------------------------------------
# C
# ------------------------------------------------------------------------------
# R config
# ------------------------------------------------------------------------------
# U config(gh)
# ------------------------------------------------------------------------------
# all
# ==============================================================================
# TODO i'm certain there's a better way to do this
CWD=$( pwd )
# 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"
;;
*arch)
OS="arch"
INS="pacman"
INS2="paru"
FLAG="-S"
;;
*raspbian | *debian)
OS="rpi"
INS="apt"
FLAG="install"
;;
*ubuntu)
OS="ubuntu"
INS="apt"
FLAG="install"
;;
*) # default
OS="unknown"
INS="unknown"
FLAG="unknown"
;;
esac
# 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
# 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 "[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
# rpi specific install
if [[ $OS -eq "rpi" ]]; then
$INS $FLAG vim
$INS $FLAG nmap
# 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 $FLAG 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 $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 specific install
if [[ $OS -eq "ubuntu" ]]; then
$INS $FLAG vim
$INS $FLAG nmap
# 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 $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 $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 $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 $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 $FLAG fonts-noto-color-emoji
$INS $FLAG discord
# install zen
curl -fsSL https://github.com/zen-browser/updates-server/raw/refs/heads/main/install.sh | sh
fi
fi
# arch specific install
if [[ $OS -eq "arch" ]]; then
$INS $FLAG vim
$INS $FLAG fastfetch
$INS $FLAG go
$INS $FLAG zig
$INS $FLAG julia
$INS $FLAG alacritty
$INS $FLAG rust
$INS $FLAG nmap
$INS $FLAG onefetch
$INS $FLAG fish
# install paru
mkdir -p ~/Documents/paru/src
git clone https://aur.archlinux.org/paru.git
cd ~/Documents/paru/src/paru
makepkg -si
# download acli ( x86 )
cd ~
curl -LO "https://acli.atlassian.com/linux/latest/acli_linux_amd64/acli"
## user specific arch install
## operating mode (server) specific arch install
if [[ $MODE -eq 2 ]]; then
$INS $FLAG gitea
#$INS $FLAG pihole
elif [[ $MODE -eq 1 ]]; then
$INS $FLAG arduino-cli
$INS $FLAG arduino-ide-bin
$INS $FLAG balena-etcher
elif [[ $MODE -eq 3 ]]; then
$INS $FLAG arduino-cli
$INS $FLAG arduino-ide-bin
$INS $FLAG balena-etcher
$INS $FLAG discord
$INS $FLAG flameshot
$INS $FLAG heroic-games-launcher
$INS2 $FLAG snapchat
$INS2 $FLAG zen-browser-bin
#zen
fi
fi
# cachyos specific install
if [[ $OS -eq "cachyos" ]]; then
$INS $FLAG go
$INS $FLAG zig
$INS $FLAG julia
$INS $FLAG rust
$INS $FLAG nmap
$INS $FLAG onefetch
# 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 $FLAG gitea
#$INS $FLAG pihole
elif [[ $MODE -eq 1 ]]; then
$INS $FLAG arduino-cli
$INS $FLAG arduino-ide-bin
$INS $FLAG balena-etcher
elif [[ $MODE -eq 3 ]]; then
$INS $FLAG arduino-cli
$INS $FLAG arduino-ide-bin
$INS $FLAG balena-etcher
$INS $FLAG discord
$INS $FLAG flameshot
$INS $FLAG heroic-games-launcher
$INS2 $FLAG snapchat
$INS $FLAG zen-browser-bin
fi
fi
# general install
$INS $FLAG cmake
$INS $FLAG lazygit
$INS $FLAG ranger
$INS $FLAG tmux
# install acli
echo "installing acli"
chmod u+x ~/acli
mv ~/acli /usr/local/bin/
## user specific general install
## operating mode specific general install
if [[ $MODE -eq 2 ]]; then
$INS $FLAG caddy
fi
# GIT_CLONES
cd ~/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
# TODO install
exit
# CONFIG
# copy over configuration files
cd $CWD
ln -r -s ./config/i3/ ~/.config/i3/
ln -r -s ./config/polybar/ ~/.config/polybar/
ln -r -s ./config/rofi/ ~/.config/rofi/
ln -r -s ./config/.tmux/ ~/.config/.tmux/
ln -r -s ./config/.vim/ ~/.vim/
ln -r -s ./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
#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"
case $USER in
# 1)
# ;;
2)
ln -s -r ~/.config/i3/bb.config ~/.config/i3/config
ln -s -r ~/.config/polybar/bb.config ~/.config/polybar/config
ln -s -r ~/.config/rofi/bb.config ~/.config/rofi/config
ln -s -r ~/.config/rofi/bb.config.rasi ~/.config/rofi/config.rasi
ln -s -r ~/.config/.tmux/bb.tmux.conf ~/.tmux.conf
;;
3)
ln -s -r ./niri/ ~/.config/niri
ln -s -r ./nirimation/ ~/.config/nirimation
;;
5)
ln -s -r ./niri/ ~/.config/niri
ln -s -r ./nirimation/ ~/.config/nirimation
;;
7)
;;
8)
;;
9)
;;
*)
;;
esac
# dynu service/timer file
#chsh -s /usr/local/bin/fish