Merge pull request #3 from blakeridgway/poc/install-rewrite
Modularize Post-Install Setup System
This commit is contained in:
commit
f2fc37b7dc
8 changed files with 789 additions and 10 deletions
124
README.md
124
README.md
|
|
@ -1,19 +1,123 @@
|
|||
# Fresh Install
|
||||
|
||||
This is a collection of items I use when I setup a fresh install.
|
||||
This is a collection of scripts and dotfiles I use when setting up a fresh Linux installation.
|
||||
|
||||
## Install
|
||||
## Quick Start
|
||||
|
||||
./post_install will run a script that installs the software that I use on daily basis, and if you have all the necessary programs installed. If you don't, it installs them for you! Once the dependencies are installed, it will run any third party installations, and create symlinks for the necessary config files in the correct locations.
|
||||
Run the main setup script to install software, configure development tools, and symlink dotfiles:
|
||||
|
||||
### Dotfiles
|
||||
```bash
|
||||
./main-setup.sh
|
||||
```
|
||||
|
||||
Here's my collection of dotfiles I use on Linux environments. I continuously add to this repo over time, as I customise my dev environment. Feel free to fork this and modify the scripts/dotfiles to suit your own needs!
|
||||
The script will automatically detect your Linux distribution (Fedora, Ubuntu, Debian, etc.) and use the appropriate package manager.
|
||||
|
||||
Git Make sure to edit the gitconfig and add your credentials instead of mine
|
||||
## What Gets Installed
|
||||
|
||||
VIM Installation Tips I use neovim and vim-plug. So if you're using regular vim you might want to remove the neovim specific plugins from my vimrc. Also, you might need to run :PlugClean to remove the plugin directories then run :PlugInstall to reinstall them.
|
||||
### Core Packages
|
||||
- Development tools: `git`, `gh`, `curl`, `wget`, `ripgrep`, `fd-find`
|
||||
- System utilities: `btop`, `fastfetch`, `zsh`, `flatpak`
|
||||
- Virtualization: `virt-manager`
|
||||
- Python: `python3`, `python3-pip`
|
||||
|
||||
### Development Environment
|
||||
- **Neovim** (latest version from GitHub)
|
||||
- **Hack Nerd Font** for terminal
|
||||
- **Oh My Zsh** shell framework
|
||||
- **Starship** prompt
|
||||
- **Rust** toolchain via rustup
|
||||
|
||||
### Fedora-Specific (.NET Development)
|
||||
On Fedora systems, additional packages are installed:
|
||||
- **Visual Studio Code**
|
||||
- **.NET SDK** (with Microsoft repository)
|
||||
- **PostgreSQL** server and tools
|
||||
- **Docker** (moby-engine) with Docker Compose
|
||||
|
||||
### Flatpak Applications
|
||||
- Bitwarden
|
||||
- Flatseal
|
||||
- Steam
|
||||
- ProtonUp-Qt
|
||||
- Rider
|
||||
- Veloren Airshipper
|
||||
- Visual Studio Code
|
||||
- VLC Media Player
|
||||
|
||||
## Modular Architecture
|
||||
|
||||
The setup is broken down into focused scripts:
|
||||
|
||||
- `00-system-prep.sh` - System updates and Flathub setup
|
||||
- `01-package-install.sh` - Core packages and Flatpak apps
|
||||
- `02-dev-tools-setup.sh` - Development tools (Neovim, fonts, shell)
|
||||
- `03-fedora-dotnet-setup.sh` - Fedora-specific .NET environment
|
||||
- `04-config-symlinks.sh` - Dotfile symlinking
|
||||
|
||||
You can run individual scripts if you only need specific components.
|
||||
|
||||
## Dotfiles
|
||||
|
||||
The following configuration files will be symlinked to your home directory:
|
||||
|
||||
- `.vimrc` & `.vim/` - Vim/Neovim configuration
|
||||
- `.zshrc` & `.zsh/` - Zsh shell configuration
|
||||
- `.gitconfig` - Git configuration (**edit with your credentials**)
|
||||
- `.gitignore` - Global Git ignore patterns
|
||||
- `.agignore` - Silver Searcher ignore patterns
|
||||
- `.aliases` - Shell aliases (from `aliases.zsh`)
|
||||
- `.gitmessage` - Git commit template (from `commit-conventions.txt`)
|
||||
|
||||
### Git Configuration
|
||||
|
||||
**Important:** Edit `gitconfig` and replace my credentials with yours before running the setup.
|
||||
|
||||
### Vim/Neovim Setup
|
||||
|
||||
I use Neovim with vim-plug for plugin management. If you're using regular Vim, you may need to:
|
||||
1. Remove Neovim-specific plugins from `.vimrc`
|
||||
2. Run `:PlugClean` to remove plugin directories
|
||||
3. Run `:PlugInstall` to reinstall compatible plugins
|
||||
|
||||
## Post-Installation Tasks
|
||||
|
||||
After running the setup, remember to:
|
||||
|
||||
1. **Configure Git with your details:**
|
||||
```bash
|
||||
git config --global user.name "Your Name"
|
||||
git config --global user.email "your.email@example.com"
|
||||
```
|
||||
|
||||
2. **Generate SSH key:**
|
||||
```bash
|
||||
ssh-keygen -t ed25519 -C ${USER}@$(hostname --fqdn)
|
||||
```
|
||||
|
||||
3. **Install Powerlevel10k gitstatus (if using):**
|
||||
```bash
|
||||
~/.oh-my-zsh/custom/themes/powerlevel10k/gitstatus/install -f
|
||||
```
|
||||
|
||||
4. **Log out and back in** for Docker group changes to take effect (Fedora)
|
||||
|
||||
5. **Install VS Code extensions** (Fedora):
|
||||
- C# Dev Kit
|
||||
- GitLens
|
||||
- Prettier
|
||||
- NuGet Package Manager GUI
|
||||
|
||||
## Supported Distributions
|
||||
|
||||
- **Fedora** (with full .NET development environment)
|
||||
- **Ubuntu/Debian** (core packages and development tools)
|
||||
- **Pop!_OS** (core packages and development tools)
|
||||
|
||||
## Customization
|
||||
|
||||
Feel free to fork this repository and modify the scripts/dotfiles to suit your needs. The modular structure makes it easy to add, remove, or modify specific components.
|
||||
|
||||
## Legacy
|
||||
|
||||
The original monolithic `post_install.sh` script has been archived in `.archive/` for reference.
|
||||
|
||||
*Things to Remember*
|
||||
`~/.oh-my-zsh/custom/themes/powerlevel10k/gitstatus/install -f`
|
||||
`ssh-keygen -t ed25519 -C ${USER}@$(hostname --fqdn)`
|
||||
|
|
|
|||
110
main-setup.sh
Executable file
110
main-setup.sh
Executable file
|
|
@ -0,0 +1,110 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Main setup script
|
||||
# Calls other scripts to perform post-installation tasks.
|
||||
|
||||
# --- Global Variables & Helper Functions ---
|
||||
# SCRIPT_ROOT_DIR will be the directory where main-setup.sh is located
|
||||
export SCRIPT_ROOT_DIR
|
||||
SCRIPT_ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
|
||||
export SCRIPTS_DIR="${SCRIPT_ROOT_DIR}/scripts"
|
||||
|
||||
# Function to detect the Linux distribution
|
||||
detect_linux_distro() {
|
||||
if [ -f /etc/os-release ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. /etc/os-release
|
||||
echo "$ID"
|
||||
elif [ -f /etc/lsb-release ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. /etc/lsb-release
|
||||
echo "$DISTRIBUTOR_ID"
|
||||
elif [ -f /etc/debian_version ]; then
|
||||
echo "debian"
|
||||
elif [ -f /etc/redhat-release ]; then
|
||||
if grep -qi "fedora" /etc/redhat-release; then
|
||||
echo "fedora"
|
||||
elif grep -qi "centos" /etc/redhat-release; then
|
||||
echo "centos"
|
||||
elif grep -qi "red hat enterprise linux" /etc/redhat-release; then
|
||||
echo "rhel"
|
||||
else
|
||||
echo "redhat"
|
||||
fi
|
||||
else
|
||||
echo "unknown"
|
||||
fi
|
||||
}
|
||||
|
||||
# Detect the Linux distribution and set package manager
|
||||
export DISTRO
|
||||
DISTRO=$(detect_linux_distro)
|
||||
|
||||
export PACKAGE_MANAGER
|
||||
case "$DISTRO" in
|
||||
fedora|rhel|centos)
|
||||
PACKAGE_MANAGER="dnf"
|
||||
;;
|
||||
debian|ubuntu|pop)
|
||||
PACKAGE_MANAGER="apt"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported distribution: $DISTRO"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Detected Distribution: $DISTRO"
|
||||
echo "Using Package Manager: $PACKAGE_MANAGER"
|
||||
echo "Script Root Directory: $SCRIPT_ROOT_DIR"
|
||||
echo "--------------------------------------------------"
|
||||
|
||||
# --- Execute Setup Scripts ---
|
||||
|
||||
echo "Executing 00-system-prep.sh..."
|
||||
if ! bash "${SCRIPTS_DIR}/00-system-prep.sh"; then
|
||||
echo "ERROR: 00-system-prep.sh failed."
|
||||
exit 1
|
||||
fi
|
||||
echo "--------------------------------------------------"
|
||||
|
||||
echo "Executing 01-package-install.sh..."
|
||||
if ! bash "${SCRIPTS_DIR}/01-package-install.sh"; then
|
||||
echo "ERROR: 01-package-install.sh failed."
|
||||
exit 1
|
||||
fi
|
||||
echo "--------------------------------------------------"
|
||||
|
||||
echo "Executing 02-dev-tools-setup.sh..."
|
||||
if ! bash "${SCRIPTS_DIR}/02-dev-tools-setup.sh"; then
|
||||
echo "ERROR: 02-dev-tools-setup.sh failed."
|
||||
exit 1
|
||||
fi
|
||||
echo "--------------------------------------------------"
|
||||
|
||||
if [ "$DISTRO" == "fedora" ]; then
|
||||
echo "Executing 03-fedora-dotnet-setup.sh..."
|
||||
if ! bash "${SCRIPTS_DIR}/03-fedora-dotnet-setup.sh"; then
|
||||
echo "ERROR: 03-fedora-dotnet-setup.sh failed."
|
||||
# Decide if this is a fatal error for the whole script
|
||||
# exit 1
|
||||
fi
|
||||
echo "--------------------------------------------------"
|
||||
fi
|
||||
|
||||
echo "Executing 04-config-symlinks.sh..."
|
||||
if ! bash "${SCRIPTS_DIR}/04-config-symlinks.sh"; then
|
||||
echo "ERROR: 04-config-symlinks.sh failed."
|
||||
# exit 1
|
||||
fi
|
||||
echo "--------------------------------------------------"
|
||||
|
||||
echo ""
|
||||
echo "#####################################"
|
||||
echo # Main setup script finished! #
|
||||
echo #####################################"
|
||||
echo "Please review the output for any manual steps or errors."
|
||||
echo "You may need to restart your terminal or log out/log in for all changes to take effect."
|
||||
|
||||
exit 0
|
||||
|
||||
34
scripts/00-system-prep.sh
Executable file
34
scripts/00-system-prep.sh
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 00-system-prep.sh
|
||||
# Updates system and sets up Flathub.
|
||||
# Relies on DISTRO and PACKAGE_MANAGER being set by the caller.
|
||||
|
||||
echo "--- Starting System Preparation ---"
|
||||
|
||||
if [ -z "$DISTRO" ] || [ -z "$PACKAGE_MANAGER" ]; then
|
||||
echo "ERROR: DISTRO and PACKAGE_MANAGER must be set in the environment."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Update system before installing packages
|
||||
echo "Updating system packages..."
|
||||
if [ "$PACKAGE_MANAGER" == "dnf" ]; then
|
||||
sudo dnf update -y && sudo dnf upgrade -y
|
||||
elif [ "$PACKAGE_MANAGER" == "apt" ]; then
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
else
|
||||
echo "WARNING: Unknown package manager '$PACKAGE_MANAGER'. Skipping system update."
|
||||
fi
|
||||
|
||||
# Setup Flatpak
|
||||
echo "Setting up Flathub repository..."
|
||||
if command -v flatpak &> /dev/null; then
|
||||
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
else
|
||||
echo "WARNING: flatpak command not found. Skipping Flathub setup."
|
||||
echo "Ensure Flatpak is installed via 01-package-install.sh or manually."
|
||||
fi
|
||||
|
||||
echo "--- System Preparation Finished ---"
|
||||
|
||||
124
scripts/01-package-install.sh
Executable file
124
scripts/01-package-install.sh
Executable file
|
|
@ -0,0 +1,124 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 01-package-install.sh
|
||||
# Installs system packages and Flatpak applications.
|
||||
# Relies on DISTRO and PACKAGE_MANAGER being set by the caller.
|
||||
|
||||
echo "--- Starting Package Installation ---"
|
||||
|
||||
if [ -z "$DISTRO" ] || [ -z "$PACKAGE_MANAGER" ]; then
|
||||
echo "ERROR: DISTRO and PACKAGE_MANAGER must be set in the environment."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Define base package list
|
||||
BASE_PACKAGE_LIST=(
|
||||
btop
|
||||
curl
|
||||
git
|
||||
gh
|
||||
fd-find
|
||||
flatpak
|
||||
python3
|
||||
python3-pip
|
||||
ripgrep
|
||||
virt-manager
|
||||
zsh
|
||||
wget
|
||||
unzip
|
||||
)
|
||||
|
||||
# Distro-specific packages to add to the main list
|
||||
DISTRO_SPECIFIC_PACKAGES=()
|
||||
if [ "$PACKAGE_MANAGER" == "dnf" ]; then
|
||||
DISTRO_SPECIFIC_PACKAGES+=(
|
||||
"fontconfig-devel" # for fc-cache
|
||||
"openssl-devel" # for various compilations
|
||||
"util-linux-user" # for chsh, if needed by OhMyZsh script
|
||||
)
|
||||
elif [ "$PACKAGE_MANAGER" == "apt" ]; then
|
||||
DISTRO_SPECIFIC_PACKAGES+=(
|
||||
"libfontconfig-dev"
|
||||
"libssl-dev"
|
||||
"fd-find" # On Debian/Ubuntu, binary is fdfind, symlink to fd often needed
|
||||
# Or user might prefer 'fd' package if available from other sources
|
||||
)
|
||||
fi
|
||||
|
||||
# Combine package lists
|
||||
PACKAGE_LIST=("${BASE_PACKAGE_LIST[@]}" "${DISTRO_SPECIFIC_PACKAGES[@]}")
|
||||
PACKAGE_LIST=($(printf "%s\n" "${PACKAGE_LIST[@]}" | LC_ALL=C sort -u))
|
||||
|
||||
|
||||
FLATPAK_LIST=(
|
||||
com.bitwarden.desktop
|
||||
com.github.tchx84.Flatseal
|
||||
com.jetbrains.Rider
|
||||
com.valvesoftware.Steam
|
||||
com.visualstudio.code
|
||||
net.davidotek.pupgui2
|
||||
net.veloren.airshipper
|
||||
org.videolan.VLC
|
||||
)
|
||||
|
||||
echo "Installing System Packages..."
|
||||
for package_name in "${PACKAGE_LIST[@]}"; do
|
||||
if [ "$PACKAGE_MANAGER" == "dnf" ]; then
|
||||
if ! rpm -q "$package_name" &>/dev/null; then
|
||||
echo "Installing $package_name (dnf)..."
|
||||
if sudo dnf install "$package_name" -y; then
|
||||
echo "$package_name has been installed."
|
||||
else
|
||||
echo "WARNING: Failed to install $package_name. It may not be available in the repositories."
|
||||
fi
|
||||
else
|
||||
echo "$package_name already installed."
|
||||
fi
|
||||
|
||||
elif [ "$PACKAGE_MANAGER" == "apt" ]; then
|
||||
# For apt, check if package provides the command or is installed
|
||||
# dpkg-query is generally more reliable for checking installed status
|
||||
actual_package_name=$package_name
|
||||
if [ "$package_name" == "fd-find" ] && ! dpkg -s fd-find &>/dev/null ; then
|
||||
# On some newer Ubuntu/Debian, 'fd-find' might be the package,
|
||||
# but user might want 'fd' if it's a different source or a metapackage.
|
||||
# For now, we stick to fd-find.
|
||||
: # Keep actual_package_name as fd-find
|
||||
fi
|
||||
|
||||
if ! dpkg-query -W -f='${Status}' "$actual_package_name" 2>/dev/null | grep -q "ok installed"; then
|
||||
echo "Installing $actual_package_name (apt)..."
|
||||
sudo apt install "$actual_package_name" -y
|
||||
echo "$actual_package_name has been installed."
|
||||
else
|
||||
echo "$actual_package_name already installed."
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Post-install for fd-find on Debian/Ubuntu (create symlink)
|
||||
if [ "$PACKAGE_MANAGER" == "apt" ] && command -v fdfind &>/dev/null && ! command -v fd &>/dev/null; then
|
||||
if dpkg-query -W -f='${Status}' "fd-find" 2>/dev/null | grep -q "ok installed"; then
|
||||
echo "Creating symlink for fd from fdfind..."
|
||||
sudo ln -sf /usr/bin/fdfind /usr/local/bin/fd # or ~/.local/bin/fd if preferred
|
||||
fi # Ensure this line is just 'fi' (and optional comment)
|
||||
fi
|
||||
|
||||
|
||||
echo "Installing Flatpak Applications..."
|
||||
if command -v flatpak &> /dev/null; then
|
||||
for flatpak_name in "${FLATPAK_LIST[@]}"; do
|
||||
if ! flatpak list --app | grep -q "$flatpak_name"; then
|
||||
echo "Installing Flatpak $flatpak_name..."
|
||||
flatpak install flathub "$flatpak_name" -y
|
||||
echo "$flatpak_name has been installed."
|
||||
else
|
||||
echo "Flatpak $flatpak_name already installed."
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "WARNING: flatpak command not found. Skipping Flatpak app installation."
|
||||
fi
|
||||
|
||||
echo "--- Package Installation Finished ---"
|
||||
|
||||
108
scripts/02-dev-tools-setup.sh
Executable file
108
scripts/02-dev-tools-setup.sh
Executable file
|
|
@ -0,0 +1,108 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 02-dev-tools-setup.sh
|
||||
# Installs various development tools and utilities.
|
||||
|
||||
echo "--- Starting Development Tools Setup ---"
|
||||
|
||||
# Setup NVIM
|
||||
echo "Setting up Neovim..."
|
||||
if command -v nvim &>/dev/null && [[ "$(nvim --version | head -n 1)" == "NVIM"* ]]; then
|
||||
echo "Neovim appears to be installed. Checking version/source or skipping."
|
||||
# Add logic here if you want to ensure it's your /opt/nvim version
|
||||
else
|
||||
echo "Downloading and installing Neovim to /opt/nvim..."
|
||||
TEMP_NVIM_DIR=$(mktemp -d)
|
||||
curl -Lo "${TEMP_NVIM_DIR}/nvim-linux64.tar.gz" https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz
|
||||
sudo rm -rf /opt/nvim
|
||||
sudo tar -C /opt -xzf "${TEMP_NVIM_DIR}/nvim-linux64.tar.gz"
|
||||
rm -rf "${TEMP_NVIM_DIR}" # Clean up
|
||||
echo "Neovim installed to /opt/nvim. Add /opt/nvim-linux64/bin to your PATH."
|
||||
# Consider adding to PATH via a profile script if not handled by zshrc/bashrc symlinks
|
||||
if [ ! -f /usr/local/bin/nvim ] && [ -d /opt/nvim-linux64/bin ]; then
|
||||
sudo ln -sf /opt/nvim-linux64/bin/nvim /usr/local/bin/nvim
|
||||
echo "Symlinked nvim to /usr/local/bin/nvim"
|
||||
fi
|
||||
fi
|
||||
|
||||
# pynvim
|
||||
echo "Installing pynvim for Neovim Python support..."
|
||||
if /usr/bin/python3 -m pip show pynvim &>/dev/null; then
|
||||
echo "pynvim already installed."
|
||||
else
|
||||
/usr/bin/python3 -m pip install --user pynvim
|
||||
echo "pynvim installed for the current user."
|
||||
fi
|
||||
|
||||
# Install Nerd Font (Hack)
|
||||
echo "Installing Hack Nerd Font..."
|
||||
NERDFONT_VERSION="v3.2.1" # Or use "latest" if API allows, else check manually
|
||||
NERDFONT_NAME="Hack"
|
||||
FONT_DIR="$HOME/.local/share/fonts"
|
||||
mkdir -p "$FONT_DIR"
|
||||
|
||||
# Check if a Hack Nerd Font is already installed to avoid re-downloading
|
||||
if fc-list | grep -qi "Hack Nerd Font"; then
|
||||
echo "Hack Nerd Font already installed."
|
||||
else
|
||||
echo "Downloading and installing Hack Nerd Font..."
|
||||
TEMP_FONT_DIR=$(mktemp -d)
|
||||
wget -qO "${TEMP_FONT_DIR}/${NERDFONT_NAME}.zip" "https://github.com/ryanoasis/nerd-fonts/releases/download/${NERDFONT_VERSION}/${NERDFONT_NAME}.zip"
|
||||
if [ $? -eq 0 ]; then
|
||||
unzip -q "${TEMP_FONT_DIR}/${NERDFONT_NAME}.zip" -d "${TEMP_FONT_DIR}/${NERDFONT_NAME}NerdFont"
|
||||
# Copy only .ttf or .otf files
|
||||
find "${TEMP_FONT_DIR}/${NERDFONT_NAME}NerdFont" \( -name "*.ttf" -o -name "*.otf" \) -exec cp {} "$FONT_DIR/" \;
|
||||
echo "Updating font cache..."
|
||||
fc-cache -f -v
|
||||
echo "Hack Nerd Font installed."
|
||||
else
|
||||
echo "ERROR: Failed to download Hack Nerd Font."
|
||||
fi
|
||||
rm -rf "${TEMP_FONT_DIR}" # Clean up
|
||||
fi
|
||||
|
||||
|
||||
# Installing OhMyZSH
|
||||
echo "Installing OhMyZSH..."
|
||||
if [ -d "$HOME/.oh-my-zsh" ]; then
|
||||
echo "OhMyZSH already installed."
|
||||
else
|
||||
echo "Attempting to install OhMyZSH. It might prompt to change your default shell."
|
||||
# CHSH=no RUNZSH=no prevents the script from trying to change shell and exit
|
||||
# The --unattended flag attempts a non-interactive install
|
||||
if sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended; then
|
||||
echo "OhMyZSH installation script finished."
|
||||
echo "If ZSH is not your default shell, change it manually: chsh -s \$(which zsh)"
|
||||
echo "Then, start a new ZSH session."
|
||||
else
|
||||
echo "ERROR: OhMyZSH installation failed."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Install Rust Up
|
||||
echo "Installing Rust via rustup..."
|
||||
if command -v rustc &>/dev/null; then
|
||||
echo "Rust (rustc) already installed."
|
||||
else
|
||||
# The -y flag automates the installation, --no-modify-path prevents it from altering .profile/.bashrc directly
|
||||
# You'll need to source "$HOME/.cargo/env" or add it to your shell's config manually
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path
|
||||
echo "Rust installed via rustup. Source \"\$HOME/.cargo/env\" or add it to your shell config."
|
||||
echo "For the current session, you can run: source \"\$HOME/.cargo/env\""
|
||||
fi
|
||||
|
||||
# Setup Starship
|
||||
echo "Installing Starship prompt..."
|
||||
if command -v starship &>/dev/null; then
|
||||
echo "Starship already installed."
|
||||
else
|
||||
# The -y flag attempts a non-interactive install
|
||||
if curl -sS https://starship.rs/install.sh | sh -s -- -y; then
|
||||
echo "Starship installed. Add 'eval \"\$(starship init zsh)\"' (or bash/fish) to your shell config."
|
||||
else
|
||||
echo "ERROR: Starship installation failed."
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "--- Development Tools Setup Finished ---"
|
||||
|
||||
248
scripts/03-fedora-dotnet-setup.sh
Executable file
248
scripts/03-fedora-dotnet-setup.sh
Executable file
|
|
@ -0,0 +1,248 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 03-fedora-dotnet-setup.sh
|
||||
# Sets up .NET Development Environment specifically for Fedora.
|
||||
# Assumes it's being run on Fedora and dnf is available.
|
||||
|
||||
echo "--- Starting Fedora .NET Development Environment Setup ---"
|
||||
|
||||
# Detect current Fedora version
|
||||
CURRENT_FEDORA_VERSION=$(rpm -E %fedora)
|
||||
echo "Detected Fedora version: $CURRENT_FEDORA_VERSION"
|
||||
|
||||
echo ""
|
||||
echo "############################################################"
|
||||
echo "# Fedora Specific: .NET Development Environment Setup #"
|
||||
echo "# #"
|
||||
echo "# Using Fedora version: $CURRENT_FEDORA_VERSION #"
|
||||
echo "# If this is a future/unsupported version, some packages #"
|
||||
echo "# or repositories might not be available yet. #"
|
||||
echo "############################################################"
|
||||
echo ""
|
||||
|
||||
FEDORA_DOTNET_PACKAGES=(
|
||||
"postgresql-server"
|
||||
"postgresql-contrib"
|
||||
"moby-engine" # Docker Engine on Fedora
|
||||
"docker-compose" # Note: might be 'podman-compose' on newer Fedora
|
||||
)
|
||||
|
||||
echo "Installing Fedora-specific packages for .NET development..."
|
||||
for pkg_name in "${FEDORA_DOTNET_PACKAGES[@]}"; do
|
||||
if ! rpm -q "$pkg_name" &>/dev/null; then
|
||||
echo "Installing $pkg_name..."
|
||||
if sudo dnf install -y "$pkg_name"; then
|
||||
echo "$pkg_name has been installed."
|
||||
else
|
||||
echo "WARNING: Failed to install $pkg_name. It may not be available in the repositories."
|
||||
# Special handling for docker-compose
|
||||
if [ "$pkg_name" == "docker-compose" ]; then
|
||||
echo "Trying alternative: podman-compose..."
|
||||
if sudo dnf install -y podman-compose; then
|
||||
echo "podman-compose installed as alternative to docker-compose."
|
||||
else
|
||||
echo "Neither docker-compose nor podman-compose could be installed."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "$pkg_name is already installed."
|
||||
fi
|
||||
done
|
||||
echo ""
|
||||
|
||||
echo "--------------------------------------------------"
|
||||
echo "I. Core .NET Development Environment"
|
||||
echo "--------------------------------------------------"
|
||||
echo "Registering Microsoft Package Repository..."
|
||||
|
||||
MS_REPO_URL_BASE="https://packages.microsoft.com/config/fedora"
|
||||
FEDORA_VERSION_FOR_MS_REPO="$CURRENT_FEDORA_VERSION"
|
||||
MS_REPO_RPM_URL="${MS_REPO_URL_BASE}/${FEDORA_VERSION_FOR_MS_REPO}/packages-microsoft-prod.rpm"
|
||||
MS_GPG_KEY_URL="https://packages.microsoft.com/keys/microsoft.asc"
|
||||
TEMP_MS_RPM_DIR=$(mktemp -d)
|
||||
TEMP_MS_RPM_PATH="${TEMP_MS_RPM_DIR}/packages-microsoft-prod-temp.rpm"
|
||||
|
||||
if ! sudo dnf repolist enabled | grep -q "packages-microsoft-com-prod"; then
|
||||
echo "Importing Microsoft GPG key: $MS_GPG_KEY_URL"
|
||||
if sudo rpm --import "$MS_GPG_KEY_URL"; then
|
||||
echo "Microsoft GPG key imported successfully."
|
||||
else
|
||||
echo "WARNING: Failed to import Microsoft GPG key."
|
||||
fi
|
||||
|
||||
echo "Downloading Microsoft package repository for Fedora $FEDORA_VERSION_FOR_MS_REPO: $MS_REPO_RPM_URL"
|
||||
if wget --quiet "$MS_REPO_RPM_URL" -O "$TEMP_MS_RPM_PATH"; then
|
||||
echo "Installing downloaded repository configuration..."
|
||||
if sudo dnf install -y "$TEMP_MS_RPM_PATH"; then
|
||||
echo "Microsoft repository RPM installed."
|
||||
else
|
||||
echo "ERROR: Failed to install Microsoft repository RPM."
|
||||
fi
|
||||
else
|
||||
echo "ERROR: Failed to download Microsoft repository RPM from $MS_REPO_RPM_URL."
|
||||
echo "This might be because Microsoft doesn't yet support Fedora $FEDORA_VERSION_FOR_MS_REPO."
|
||||
echo "You can try using a previous Fedora version number or install .NET manually."
|
||||
|
||||
# Fallback: try with previous Fedora version
|
||||
FALLBACK_VERSION=$((CURRENT_FEDORA_VERSION - 1))
|
||||
echo "Trying fallback with Fedora $FALLBACK_VERSION..."
|
||||
FALLBACK_URL="${MS_REPO_URL_BASE}/${FALLBACK_VERSION}/packages-microsoft-prod.rpm"
|
||||
if wget --quiet "$FALLBACK_URL" -O "$TEMP_MS_RPM_PATH"; then
|
||||
echo "Fallback download successful. Installing..."
|
||||
sudo dnf install -y "$TEMP_MS_RPM_PATH"
|
||||
else
|
||||
echo "Fallback also failed. Skipping Microsoft repository setup."
|
||||
fi
|
||||
fi
|
||||
sudo rm -rf "$TEMP_MS_RPM_DIR" # Clean up
|
||||
else
|
||||
echo "Microsoft package repository already configured."
|
||||
fi
|
||||
|
||||
echo "Installing .NET SDK..."
|
||||
# Try different .NET SDK package names
|
||||
DOTNET_SDK_PACKAGES=("dotnet-sdk-8.0" "dotnet-sdk-9.0" "dotnet")
|
||||
DOTNET_INSTALLED=false
|
||||
|
||||
for sdk_package in "${DOTNET_SDK_PACKAGES[@]}"; do
|
||||
if rpm -q "$sdk_package" &>/dev/null; then
|
||||
echo ".NET SDK ($sdk_package) already installed."
|
||||
DOTNET_INSTALLED=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$DOTNET_INSTALLED" = false ]; then
|
||||
for sdk_package in "${DOTNET_SDK_PACKAGES[@]}"; do
|
||||
echo "Attempting to install $sdk_package..."
|
||||
if sudo dnf install -y "$sdk_package"; then
|
||||
echo ".NET SDK ($sdk_package) installed successfully."
|
||||
DOTNET_INSTALLED=true
|
||||
break
|
||||
else
|
||||
echo "Failed to install $sdk_package, trying next option..."
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$DOTNET_INSTALLED" = false ]; then
|
||||
echo "ERROR: Failed to install any .NET SDK package."
|
||||
echo "You may need to install .NET manually from https://dotnet.microsoft.com/"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "To verify .NET Installation, run these commands manually:"
|
||||
echo " dotnet --version"
|
||||
echo " dotnet --list-sdks"
|
||||
echo " dotnet --list-runtimes"
|
||||
echo ""
|
||||
|
||||
echo "--------------------------------------------------"
|
||||
echo "II. Code Editor/IDE (Visual Studio Code)"
|
||||
echo "--------------------------------------------------"
|
||||
echo "Visual Studio Code (package 'code') should have been installed."
|
||||
echo "Open VS Code and install these essential extensions from the Extensions view (Ctrl+Shift+X):"
|
||||
echo " - C# Dev Kit (Publisher: Microsoft)"
|
||||
echo " - (Optional but Recommended) NuGet Package Manager GUI"
|
||||
echo " - (Optional but Recommended) GitLens"
|
||||
echo " - (Optional but Recommended) Prettier - Code formatter"
|
||||
echo " - (Optional) Any Blazor-specific snippet or tooling extensions"
|
||||
echo "Restart VS Code if prompted after extension installations."
|
||||
echo ""
|
||||
|
||||
echo "--------------------------------------------------"
|
||||
echo "III. Version Control (Git)"
|
||||
echo "--------------------------------------------------"
|
||||
echo "Git (package 'git') should have been installed by 01-package-install.sh."
|
||||
echo "Configure Git with your details by running these commands:"
|
||||
echo " git config --global user.name \"Your Name\""
|
||||
echo " git config --global user.email \"youremail@example.com\""
|
||||
echo ""
|
||||
|
||||
echo "--------------------------------------------------"
|
||||
echo "IV. Web Browser for Frontend Testing"
|
||||
echo "--------------------------------------------------"
|
||||
echo "Ensure you have a modern web browser (e.g., Firefox, usually pre-installed on Fedora)."
|
||||
echo "If needed, you can install Chromium with: sudo dnf install -y chromium"
|
||||
echo "Familiarize yourself with its Developer Tools (Inspector, Console, Network)."
|
||||
echo ""
|
||||
|
||||
echo "--------------------------------------------------"
|
||||
echo "V. Database (Optional - PostgreSQL Example)"
|
||||
echo "--------------------------------------------------"
|
||||
echo "PostgreSQL server and contrib packages should have been installed."
|
||||
if command -v postgresql-setup &>/dev/null; then
|
||||
echo "Initializing PostgreSQL Database Cluster (if not already done)..."
|
||||
# Fixed the postgresql-setup command
|
||||
if sudo postgresql-setup --initdb; then
|
||||
echo "PostgreSQL database cluster initialized."
|
||||
else
|
||||
echo "PostgreSQL initialization failed or was already done."
|
||||
fi
|
||||
else
|
||||
echo "WARNING: postgresql-setup command not found. Manual initialization might be needed."
|
||||
fi
|
||||
|
||||
echo "Enabling and Starting PostgreSQL Service..."
|
||||
if sudo systemctl enable --now postgresql; then
|
||||
echo "PostgreSQL service enabled and started."
|
||||
else
|
||||
echo "WARNING: Failed to enable/start PostgreSQL service."
|
||||
fi
|
||||
|
||||
echo "To create a PostgreSQL User and Database, run the following commands:"
|
||||
echo " 1. Access psql: sudo -u postgres psql"
|
||||
echo " 2. Inside psql, execute (replace placeholders):"
|
||||
echo " CREATE USER myappuser WITH PASSWORD 'yoursecurepassword';"
|
||||
echo " CREATE DATABASE myappdb OWNER myappuser;"
|
||||
echo " 3. Exit psql: \\q"
|
||||
echo "(Optional) Install a PostgreSQL GUI Tool like pgAdmin 4:"
|
||||
echo " sudo dnf install -y pgadmin4"
|
||||
echo "Or DBeaver (download from their website or check Fedora repos/Flathub)."
|
||||
echo ""
|
||||
|
||||
echo "--------------------------------------------------"
|
||||
echo "VI. Containerization (Optional but Recommended - Docker)"
|
||||
echo "--------------------------------------------------"
|
||||
echo "Docker Engine (moby-engine) and Docker Compose should have been installed."
|
||||
echo "Enabling and Starting Docker Service..."
|
||||
if sudo systemctl enable --now docker; then
|
||||
echo "Docker service enabled and started."
|
||||
else
|
||||
echo "WARNING: Failed to enable/start Docker service."
|
||||
fi
|
||||
|
||||
echo "Adding current user ($USER) to the Docker group..."
|
||||
if sudo usermod -aG docker "$USER"; then
|
||||
echo "User added to docker group successfully."
|
||||
else
|
||||
echo "WARNING: Failed to add user to docker group."
|
||||
fi
|
||||
|
||||
echo "IMPORTANT: You MUST log out and log back in for this group change to take effect."
|
||||
echo "After logging back in, verify Docker Installation by running:"
|
||||
echo " docker --version"
|
||||
echo " docker-compose --version (or podman-compose --version)"
|
||||
echo " docker run hello-world"
|
||||
echo ""
|
||||
|
||||
echo "--------------------------------------------------"
|
||||
echo "VII. Final Checks for .NET Setup"
|
||||
echo "--------------------------------------------------"
|
||||
echo "Consider rebooting your system to ensure all services and paths are correctly initialized: sudo reboot"
|
||||
echo "After setup (and potential relogin for Docker), create a Test .NET Project:"
|
||||
echo " mkdir -p ~/dotnet_test_projects && cd ~/dotnet_test_projects"
|
||||
echo " dotnet new webapi -o TestApi"
|
||||
echo " cd TestApi"
|
||||
echo " dotnet run # (and check in browser at http://localhost:5000 or https://localhost:5001)"
|
||||
echo " cd .."
|
||||
echo " dotnet new blazorserver -o TestBlazorApp # or blazorwasm"
|
||||
echo " cd TestBlazorApp"
|
||||
echo " dotnet run # (and check in browser)"
|
||||
echo ""
|
||||
echo "############################################################"
|
||||
echo "# End of Fedora Specific .NET Setup #"
|
||||
echo "############################################################"
|
||||
|
||||
echo "--- Fedora .NET Development Environment Setup Finished ---"
|
||||
|
||||
51
scripts/04-config-symlinks.sh
Executable file
51
scripts/04-config-symlinks.sh
Executable file
|
|
@ -0,0 +1,51 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 04-config-symlinks.sh
|
||||
# Copies Starship config and symlinks dotfiles.
|
||||
# Relies on SCRIPT_ROOT_DIR being set by the caller.
|
||||
|
||||
echo "--- Starting Configuration and Symlinking ---"
|
||||
|
||||
if [ -z "$SCRIPT_ROOT_DIR" ]; then
|
||||
echo "ERROR: SCRIPT_ROOT_DIR must be set in the environment."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Starship Config File
|
||||
STARSHIP_CONFIG_SOURCE="${SCRIPT_ROOT_DIR}/terminal/starship.toml"
|
||||
STARSHIP_CONFIG_DEST_DIR="$HOME/.config"
|
||||
STARSHIP_CONFIG_DEST_FILE="${STARSHIP_CONFIG_DEST_DIR}/starship.toml"
|
||||
|
||||
echo "Setting up Starship configuration..."
|
||||
if [ -f "$STARSHIP_CONFIG_SOURCE" ]; then
|
||||
mkdir -p "$STARSHIP_CONFIG_DEST_DIR"
|
||||
cp "$STARSHIP_CONFIG_SOURCE" "$STARSHIP_CONFIG_DEST_FILE"
|
||||
echo "Copied starship.toml to $STARSHIP_CONFIG_DEST_FILE"
|
||||
else
|
||||
echo "WARNING: Starship config source not found: $STARSHIP_CONFIG_SOURCE. Skipping copy."
|
||||
fi
|
||||
|
||||
# Symlink files (keeping the original simple approach)
|
||||
echo "Symlinking dotfiles..."
|
||||
FILES=('vimrc' 'vim' 'zshrc' 'zsh' 'agignore' 'gitconfig' 'gitignore' 'commit-conventions.txt' 'aliases.zsh')
|
||||
|
||||
for file in "${FILES[@]}"; do
|
||||
echo ""
|
||||
echo "Symlinking $file to $HOME"
|
||||
|
||||
# Check if source file exists first
|
||||
if [ -e "${SCRIPT_ROOT_DIR}/${file}" ]; then
|
||||
ln -sf "${SCRIPT_ROOT_DIR}/${file}" "$HOME/.$file"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "${SCRIPT_ROOT_DIR}/${file} ~> $HOME/.$file"
|
||||
else
|
||||
echo "Install failed to symlink $file."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "WARNING: Source file not found: ${SCRIPT_ROOT_DIR}/${file}. Skipping."
|
||||
fi
|
||||
done
|
||||
|
||||
echo "--- Configuration and Symlinking Finished ---"
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue