mirror of
https://github.com/zebrajr/HomeLab.git
synced 2025-12-06 00:20:22 +01:00
initial fedora-bootstrap commit
This commit is contained in:
parent
0c6449302e
commit
d9179a62f5
17
fedora-bootstrap/README.md
Normal file
17
fedora-bootstrap/README.md
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
# Bash System Bootstraper
|
||||||
|
|
||||||
|
Bash based "ansible-look-a-like"
|
||||||
|
|
||||||
|
An attempt at bootstrapping a Linux System - initially just Fedora Minimal - to a Full Running OS with bash.
|
||||||
|
|
||||||
|
The `Win Goal` is to be the same - or better - then installing Fedora KDE Plasma and then using the Ansible Playbook to get the host 99% ready to use.
|
||||||
|
|
||||||
|
## Before First Run
|
||||||
|
|
||||||
|
## Configuring and What's What
|
||||||
|
|
||||||
|
## Running
|
||||||
|
|
||||||
|
- Configure `settings.json`
|
||||||
|
|
||||||
|
- Run `sudo ./bootstrap.sh`
|
||||||
44
fedora-bootstrap/bootstrap.sh
Executable file
44
fedora-bootstrap/bootstrap.sh
Executable file
|
|
@ -0,0 +1,44 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# set strict error handling
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
|
||||||
|
# --- Environment Checks ---
|
||||||
|
[ "$(id -u)" -eq 0 ] || { echo "Run with sudo!" >&2; exit 1; }
|
||||||
|
grep -q "Fedora" /etc/os-release || { echo "Only Fedora supported!"; exit 1; }
|
||||||
|
|
||||||
|
|
||||||
|
# Source Utils
|
||||||
|
source_utils() {
|
||||||
|
for CONFIG in ./utils/*.sh; do
|
||||||
|
echo "[+] sourcing $CONFIG"
|
||||||
|
source "$CONFIG"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
main(){
|
||||||
|
# Source Utils
|
||||||
|
source_utils
|
||||||
|
stopwatch_start
|
||||||
|
|
||||||
|
# Source Main Settings
|
||||||
|
source_settings
|
||||||
|
|
||||||
|
# Source Specifically declared configurations
|
||||||
|
source_selected_configs
|
||||||
|
|
||||||
|
# Source config.d scripts
|
||||||
|
source_config_directory
|
||||||
|
|
||||||
|
# Packages
|
||||||
|
install_packages
|
||||||
|
remove_packages
|
||||||
|
|
||||||
|
# Clean Up
|
||||||
|
stopwatch_end
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
main "$@"
|
||||||
13
fedora-bootstrap/config.d/core_packages.conf
Normal file
13
fedora-bootstrap/config.d/core_packages.conf
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PACKAGES_TO_INSTALL+=("btop")
|
||||||
|
PACKAGES_TO_INSTALL+=("curl")
|
||||||
|
PACKAGES_TO_INSTALL+=("duf")
|
||||||
|
PACKAGES_TO_INSTALL+=("fzf")
|
||||||
|
PACKAGES_TO_INSTALL+=("gparted")
|
||||||
|
PACKAGES_TO_INSTALL+=("htop")
|
||||||
|
PACKAGES_TO_INSTALL+=("konsole")
|
||||||
|
PACKAGES_TO_INSTALL+=("ncdu")
|
||||||
|
PACKAGES_TO_INSTALL+=("rsync")
|
||||||
|
PACKAGES_TO_INSTALL+=("timeshift")
|
||||||
|
PACKAGES_TO_INSTALL+=("tmux")
|
||||||
6
fedora-bootstrap/config.d/packages_battlestation.conf
Normal file
6
fedora-bootstrap/config.d/packages_battlestation.conf
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PACKAGES_TO_INSTALL+=("bottles")
|
||||||
|
PACKAGES_TO_INSTALL+=("clementine")
|
||||||
|
PACKAGES_TO_INSTALL+=("gamescope")
|
||||||
|
PACKAGES_TO_INSTALL+=("steam")
|
||||||
3
fedora-bootstrap/config.d/packages_designing.conf
Normal file
3
fedora-bootstrap/config.d/packages_designing.conf
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PACKAGES_TO_INSTALL+=("inkscape")
|
||||||
17
fedora-bootstrap/config.d/packages_developer.conf
Normal file
17
fedora-bootstrap/config.d/packages_developer.conf
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PACKAGES_TO_INSTALL+=("bridge-utils")
|
||||||
|
PACKAGES_TO_INSTALL+=("docker")
|
||||||
|
PACKAGES_TO_INSTALL+=("docker-compose")
|
||||||
|
PACKAGES_TO_INSTALL+=("git")
|
||||||
|
PACKAGES_TO_INSTALL+=("golang")
|
||||||
|
#PACKAGES_TO_INSTALL+=("heaptrack")
|
||||||
|
PACKAGES_TO_INSTALL+=("libvirt")
|
||||||
|
PACKAGES_TO_INSTALL+=("neovim")
|
||||||
|
PACKAGES_TO_INSTALL+=("nmap")
|
||||||
|
PACKAGES_TO_INSTALL+=("nmtui")
|
||||||
|
PACKAGES_TO_INSTALL+=("nodejs")
|
||||||
|
PACKAGES_TO_INSTALL+=("qemu-kvm")
|
||||||
|
PACKAGES_TO_INSTALL+=("vim")
|
||||||
|
PACKAGES_TO_INSTALL+=("virt-manager")
|
||||||
|
PACKAGES_TO_INSTALL+=("wget")
|
||||||
3
fedora-bootstrap/config.d/packages_gamedev.conf
Normal file
3
fedora-bootstrap/config.d/packages_gamedev.conf
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PACKAGES_TO_INSTALL+=("godot")
|
||||||
13
fedora-bootstrap/config.d/packages_hyprland_wm.conf
Normal file
13
fedora-bootstrap/config.d/packages_hyprland_wm.conf
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Hyprland WM
|
||||||
|
PACKAGES_TO_INSTALL+=("ark")
|
||||||
|
PACKAGES_TO_INSTALL+=("dolphin")
|
||||||
|
PACKAGES_TO_INSTALL+=("dunst")
|
||||||
|
PACKAGES_TO_INSTALL+=("hyprland")
|
||||||
|
PACKAGES_TO_INSTALL+=("hyprlock")
|
||||||
|
PACKAGES_TO_INSTALL+=("hyprpaper")
|
||||||
|
PACKAGES_TO_INSTALL+=("hyprpolkitagent")
|
||||||
|
PACKAGES_TO_INSTALL+=("pavucontrol")
|
||||||
|
PACKAGES_TO_INSTALL+=("waybar")
|
||||||
|
PACKAGES_TO_INSTALL+=("wdisplays")
|
||||||
4
fedora-bootstrap/config.d/packages_kde_plasma.conf
Normal file
4
fedora-bootstrap/config.d/packages_kde_plasma.conf
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# KDE Desktop
|
||||||
|
PACKAGES_TO_INSTALL+=("@kde-desktop")
|
||||||
8
fedora-bootstrap/config.d/packages_workstation.conf
Normal file
8
fedora-bootstrap/config.d/packages_workstation.conf
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PACKAGES_TO_INSTALL+=("firefox")
|
||||||
|
PACKAGES_TO_INSTALL+=("flameshot")
|
||||||
|
PACKAGES_TO_INSTALL+=("keepassxc")
|
||||||
|
PACKAGES_TO_INSTALL+=("libreoffice")
|
||||||
|
PACKAGES_TO_INSTALL+=("syncthing")
|
||||||
|
PACKAGES_TO_INSTALL+=("vlc")
|
||||||
3
fedora-bootstrap/config.d/remove_bloatware.conf
Normal file
3
fedora-bootstrap/config.d/remove_bloatware.conf
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PACKAGES_TO_REMOVE+=("@gnome-desktop")
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# [:TODO:] this should handle multiple package managers eg: apt, yum, dnf
|
||||||
|
|
||||||
|
local INSTALL_OPTIONS=""
|
||||||
|
if ! $VERBOSE_MODE; then
|
||||||
|
INSTALL_OPTIONS+=" > /dev/null"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[.] Enabling copr | solopasha/hyprland"
|
||||||
|
eval "sudo dnf copr enable solopasha/hyprland -y $INSTALL_OPTIONS 2>&1"
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/bash
|
||||||
|
sudo dnf install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm -y > /dev/null 2>&1
|
||||||
7
fedora-bootstrap/playbooks/system/enable_sddm.conf
Normal file
7
fedora-bootstrap/playbooks/system/enable_sddm.conf
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!bin/bash
|
||||||
|
|
||||||
|
echo "[.] Disable gdm"
|
||||||
|
sudo systemctl disable gdm
|
||||||
|
echo "[.] Enable sddm"
|
||||||
|
sudo systemctl enable sddm
|
||||||
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# can be manually started with systemctl start graphical.target
|
||||||
|
echo "[.] Setting Desktop Default to Graphical"
|
||||||
|
sudo systemctl set-default graphical.target
|
||||||
5
fedora-bootstrap/playbooks/system/set_hostname.conf
Normal file
5
fedora-bootstrap/playbooks/system/set_hostname.conf
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
sudo hostnamectl set-hostname "$MACHINE_HOSTNAME"
|
||||||
|
|
||||||
|
echo "[.] Set hostname to: $(hostname)"
|
||||||
27
fedora-bootstrap/settings.conf
Normal file
27
fedora-bootstrap/settings.conf
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/bash
|
||||||
|
VERBOSE_MODE=false
|
||||||
|
|
||||||
|
MACHINE_HOSTNAME="homelabtest"
|
||||||
|
|
||||||
|
# Default Package Manager to Use
|
||||||
|
PKG_MGR="dnf"
|
||||||
|
#PKG_MGR_OPTIONS="-y"
|
||||||
|
|
||||||
|
# List of Config Files to Source
|
||||||
|
# Comment Out anything not needed / desired
|
||||||
|
SOURCE_CONFIG_FILE=()
|
||||||
|
SOURCE_CONFIG_FILE+=("playbooks/system/set_hostname")
|
||||||
|
SOURCE_CONFIG_FILE+=("playbooks/repositories/enable_rpmfusion_nonfree")
|
||||||
|
SOURCE_CONFIG_FILE+=("playbooks/repositories/enable_hyprland_repo")
|
||||||
|
SOURCE_CONFIG_FILE+=("playbooks/system/enable_sddm")
|
||||||
|
SOURCE_CONFIG_FILE+=("playbooks/system/set_default_desktop_graphical")
|
||||||
|
|
||||||
|
|
||||||
|
# List of Directories to Source ALL files that match the extension
|
||||||
|
# NOT IMPLEMENTED YET
|
||||||
|
#SOURCE_CUSTOM_DIRECTORIES=()
|
||||||
|
#SOURCE_CUSTOM_DIRECTORIES_EXTENSION=".conf"
|
||||||
|
|
||||||
|
# Making sure variable is available
|
||||||
|
PACKAGES_TO_INSTALL=()
|
||||||
|
PACKAGES_TO_REMOVE=()
|
||||||
66
fedora-bootstrap/utils/bootstraper.sh
Normal file
66
fedora-bootstrap/utils/bootstraper.sh
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Getting the main settings.conf file
|
||||||
|
source_settings(){
|
||||||
|
echo "[+] sourcing settings.conf"
|
||||||
|
source settings.conf
|
||||||
|
}
|
||||||
|
|
||||||
|
# Sources entire config.d directory
|
||||||
|
source_config_directory() {
|
||||||
|
for CONFIG in ./config.d/*.conf; do
|
||||||
|
echo "[+] Sourcing $CONFIG"
|
||||||
|
source "$CONFIG"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install everything that was added to PACKAGES_TO_INSTALL
|
||||||
|
install_packages() {
|
||||||
|
INSTALL_OPTIONS=""
|
||||||
|
|
||||||
|
# Check if VERBOSE_MODE is off
|
||||||
|
if ! $VERBOSE_MODE; then
|
||||||
|
INSTALL_OPTIONS+=" > /dev/null"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for TARGET_PACKAGE in "${PACKAGES_TO_INSTALL[@]}"; do
|
||||||
|
echo "[.] Installing $TARGET_PACKAGE"
|
||||||
|
eval "sudo $PKG_MGR install $TARGET_PACKAGE -y $INSTALL_OPTIONS 2>&1"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_packages() {
|
||||||
|
INSTALL_OPTIONS=""
|
||||||
|
|
||||||
|
# Check if VERBOSE_MODE is off
|
||||||
|
if ! $VERBOSE_MODE; then
|
||||||
|
INSTALL_OPTIONS+=" > /dev/null"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for TARGET_PACKAGE in "${PACKAGES_TO_REMOVE[@]}"; do
|
||||||
|
echo "[.] Removing $TARGET_PACKAGE"
|
||||||
|
eval "sudo $PKG_MGR remove $TARGET_PACKAGE -y $INSTALL_OPTIONS 2>&1"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
source_target_directory() {
|
||||||
|
local TARGET_DIRECTORY="$1"
|
||||||
|
SOURCE_PATH="./${TARGET_DIRECTORY}/*.conf"
|
||||||
|
for CONFIG in $SOURCE_PATH; do
|
||||||
|
echo "[+] Sourcing $CONFIG"
|
||||||
|
source "$CONFIG"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Sources files declared in SOURCE_CONFIG_FILE
|
||||||
|
source_selected_configs() {
|
||||||
|
for CONFIG in "${SOURCE_CONFIG_FILE[@]}"; do
|
||||||
|
SOURCE_PATH="./${CONFIG}.conf"
|
||||||
|
echo "[+] Sourcing $SOURCE_PATH"
|
||||||
|
source "$SOURCE_PATH"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Prevent the script from executing when sourced
|
||||||
|
return 0 2>/dev/null
|
||||||
|
exit 0
|
||||||
40
fedora-bootstrap/utils/stopwatch.sh
Normal file
40
fedora-bootstrap/utils/stopwatch.sh
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function stopwatch_start {
|
||||||
|
echo ""
|
||||||
|
echo "---------------------------"
|
||||||
|
echo "[.] Stopwatch started"
|
||||||
|
echo "---------------------------"
|
||||||
|
echo ""
|
||||||
|
start_time=$(date +%s)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Function to display the elapsed time
|
||||||
|
function stopwatch_elapsed {
|
||||||
|
local elapsed=$((end_time - start_time))
|
||||||
|
local days=$((elapsed/60/60/24))
|
||||||
|
local hours=$((elapsed/60/60%24))
|
||||||
|
local minutes=$((elapsed/60%60))
|
||||||
|
local seconds=$((elapsed%60))
|
||||||
|
echo ""
|
||||||
|
echo "---------------------------"
|
||||||
|
printf "Time Elapsed: %02d:%02d\n" $minutes $seconds
|
||||||
|
echo "---------------------------"
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to end the stopwatch
|
||||||
|
function stopwatch_end {
|
||||||
|
end_time=$(date +%s)
|
||||||
|
echo ""
|
||||||
|
echo "---------------------------"
|
||||||
|
echo "[.] Stopwatch stopped"
|
||||||
|
echo "---------------------------"
|
||||||
|
echo ""
|
||||||
|
stopwatch_elapsed
|
||||||
|
}
|
||||||
|
|
||||||
|
# Prevent the script from executing when sourced
|
||||||
|
return 0 2>/dev/null
|
||||||
|
exit 0
|
||||||
Loading…
Reference in New Issue
Block a user