mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 02:20:11 -08:00
Enhance setup scripts to detect OS and determine package manager
- Improved OS detection in bootstrap.sh and setup.sh to handle unsupported OS cases. - Added a function to determine the package manager (nala, dnf, apt) based on the detected OS. - Updated package installation commands to use the appropriate package manager. - Enhanced user feedback with colored output for better visibility during setup and updates.
This commit is contained in:
@@ -11,10 +11,48 @@ NC='\033[0m' # No Color
|
|||||||
|
|
||||||
echo -e "${GREEN}Setting up your system...${NC}"
|
echo -e "${GREEN}Setting up your system...${NC}"
|
||||||
|
|
||||||
|
# Detect OS
|
||||||
|
if [ -f /etc/os-release ]; then
|
||||||
|
. /etc/os-release
|
||||||
|
OS_NAME=$ID
|
||||||
|
OS_VERSION=$VERSION_ID
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}Unable to detect OS, assuming Debian/Ubuntu...${NC}"
|
||||||
|
OS_NAME="ubuntu"
|
||||||
|
OS_VERSION="22.04"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${GREEN}Detected OS: ${OS_NAME} ${OS_VERSION}${NC}"
|
||||||
|
|
||||||
|
# Function to determine the package manager to use
|
||||||
|
determine_pkg_manager() {
|
||||||
|
if command -v nala &> /dev/null; then
|
||||||
|
echo "nala"
|
||||||
|
elif [ "$OS_NAME" = "fedora" ]; then
|
||||||
|
echo "dnf"
|
||||||
|
else
|
||||||
|
echo "apt"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Determine which package manager to use
|
||||||
|
PKG_MANAGER=$(determine_pkg_manager)
|
||||||
|
echo -e "${GREEN}Using package manager: $PKG_MANAGER${NC}"
|
||||||
|
|
||||||
# Install git if not present
|
# Install git if not present
|
||||||
if ! command -v git &>/dev/null; then
|
if ! command -v git &>/dev/null; then
|
||||||
echo -e "${YELLOW}Installing git...${NC}"
|
echo -e "${YELLOW}Installing git...${NC}"
|
||||||
sudo apt update && sudo apt install -y git
|
case $PKG_MANAGER in
|
||||||
|
nala)
|
||||||
|
sudo nala install -y git
|
||||||
|
;;
|
||||||
|
dnf)
|
||||||
|
sudo dnf install -y git
|
||||||
|
;;
|
||||||
|
apt)
|
||||||
|
sudo apt update && sudo apt install -y git
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create shell directory if it doesn't exist
|
# Create shell directory if it doesn't exist
|
||||||
|
|||||||
314
setup/setup.sh
314
setup/setup.sh
@@ -8,103 +8,201 @@ DOTFILES_SUBDIR="$DOTFILES_DIR/dotfiles"
|
|||||||
# Colors for output
|
# Colors for output
|
||||||
GREEN='\033[0;32m'
|
GREEN='\033[0;32m'
|
||||||
YELLOW='\033[0;33m'
|
YELLOW='\033[0;33m'
|
||||||
|
RED='\033[0;31m'
|
||||||
NC='\033[0m' # No Color
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
echo -e "${GREEN}Starting system setup...${NC}"
|
echo -e "${GREEN}Starting system setup...${NC}"
|
||||||
|
|
||||||
# Add apt repositories
|
# Detect OS
|
||||||
echo -e "${YELLOW}Setting up apt repositories...${NC}"
|
if [ -f /etc/os-release ]; then
|
||||||
|
. /etc/os-release
|
||||||
# Install prerequisites
|
OS_NAME=$ID
|
||||||
sudo apt-get install -y wget gpg apt-transport-https
|
OS_VERSION=$VERSION_ID
|
||||||
|
|
||||||
# Setup Nala repository - Try multiple methods
|
|
||||||
echo -e "${YELLOW}Setting up Nala repository...${NC}"
|
|
||||||
|
|
||||||
# First check if Nala is available in standard repositories (newer Ubuntu versions)
|
|
||||||
if apt-cache show nala &>/dev/null; then
|
|
||||||
echo -e "${GREEN}Nala is available in standard repositories${NC}"
|
|
||||||
else
|
else
|
||||||
echo -e "${YELLOW}Nala not found in standard repositories. Trying alternative installation methods...${NC}"
|
echo -e "${YELLOW}Unable to detect OS, assuming Debian/Ubuntu...${NC}"
|
||||||
|
OS_NAME="ubuntu"
|
||||||
# Check Ubuntu version
|
OS_VERSION="22.04"
|
||||||
if grep -q "noble\|lunar\|mantic\|jammy" /etc/os-release; then
|
fi
|
||||||
echo -e "${GREEN}Ubuntu $(grep VERSION_CODENAME /etc/os-release | cut -d= -f2) detected. Ensuring universe repository is enabled...${NC}"
|
|
||||||
# Make sure universe repository is enabled
|
echo -e "${GREEN}Detected OS: ${OS_NAME} ${OS_VERSION}${NC}"
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y software-properties-common
|
# Function to determine the package manager to use
|
||||||
sudo add-apt-repository -y universe
|
determine_pkg_manager() {
|
||||||
|
if command -v nala &> /dev/null; then
|
||||||
|
echo "nala"
|
||||||
|
elif [ "$OS_NAME" = "fedora" ]; then
|
||||||
|
echo "dnf"
|
||||||
|
else
|
||||||
|
echo "apt"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set up package management based on OS
|
||||||
|
if [ "$OS_NAME" = "fedora" ]; then
|
||||||
|
echo -e "${YELLOW}Setting up Fedora repositories and package management...${NC}"
|
||||||
|
|
||||||
|
# Install prerequisites for Fedora
|
||||||
|
sudo dnf install -y wget gpg
|
||||||
|
|
||||||
|
# Setup VS Code repository for Fedora
|
||||||
|
echo -e "${YELLOW}Setting up VS Code repository for Fedora...${NC}"
|
||||||
|
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
|
||||||
|
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
|
||||||
|
|
||||||
|
# Setup GitHub CLI repository for Fedora
|
||||||
|
echo -e "${YELLOW}Setting up GitHub CLI repository for Fedora...${NC}"
|
||||||
|
sudo dnf install -y 'dnf-command(config-manager)'
|
||||||
|
# Use a different approach to add the GitHub CLI repo to avoid the "--add-repo" error
|
||||||
|
sudo curl -fsSL https://cli.github.com/packages/rpm/gh-cli.repo -o /etc/yum.repos.d/gh-cli.repo
|
||||||
|
|
||||||
|
# Update package lists
|
||||||
|
echo -e "${YELLOW}Updating package lists for Fedora...${NC}"
|
||||||
|
sudo dnf check-update -y || true
|
||||||
|
|
||||||
|
else
|
||||||
|
# Add apt repositories for Debian/Ubuntu
|
||||||
|
echo -e "${YELLOW}Setting up apt repositories...${NC}"
|
||||||
|
|
||||||
|
# Install prerequisites
|
||||||
|
sudo apt-get install -y wget gpg apt-transport-https
|
||||||
|
|
||||||
|
# Setup Nala repository - Try multiple methods
|
||||||
|
echo -e "${YELLOW}Setting up Nala repository...${NC}"
|
||||||
|
|
||||||
|
# First check if Nala is available in standard repositories (newer Ubuntu versions)
|
||||||
|
if apt-cache show nala &>/dev/null; then
|
||||||
|
echo -e "${GREEN}Nala is available in standard repositories${NC}"
|
||||||
else
|
else
|
||||||
# For older Ubuntu versions try to install directly
|
echo -e "${YELLOW}Nala not found in standard repositories. Trying alternative installation methods...${NC}"
|
||||||
echo -e "${YELLOW}Older Ubuntu version detected. Trying to install Nala directly...${NC}"
|
|
||||||
sudo apt-get update
|
# Check Ubuntu version
|
||||||
sudo apt-get install -y software-properties-common
|
if grep -q "noble\|lunar\|mantic\|jammy" /etc/os-release; then
|
||||||
|
echo -e "${GREEN}Ubuntu $(grep VERSION_CODENAME /etc/os-release | cut -d= -f2) detected. Ensuring universe repository is enabled...${NC}"
|
||||||
|
# Make sure universe repository is enabled
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y software-properties-common
|
||||||
|
sudo add-apt-repository -y universe
|
||||||
|
else
|
||||||
|
# For older Ubuntu versions try to install directly
|
||||||
|
echo -e "${YELLOW}Older Ubuntu version detected. Trying to install Nala directly...${NC}"
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y software-properties-common
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Setup VS Code repository
|
||||||
|
echo -e "${YELLOW}Setting up VS Code repository...${NC}"
|
||||||
|
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /tmp/packages.microsoft.gpg
|
||||||
|
sudo install -D -o root -g root -m 644 /tmp/packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
|
||||||
|
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
|
||||||
|
rm /tmp/packages.microsoft.gpg
|
||||||
|
|
||||||
|
# Setup GitHub CLI repository
|
||||||
|
echo -e "${YELLOW}Setting up GitHub CLI repository...${NC}"
|
||||||
|
sudo mkdir -p -m 755 /etc/apt/keyrings
|
||||||
|
out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
|
||||||
|
&& sudo install -D -o root -g root -m 644 "$out" /etc/apt/keyrings/githubcli-archive-keyring.gpg \
|
||||||
|
&& rm "$out" \
|
||||||
|
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
|
||||||
|
|
||||||
|
# Update package lists (ignoring previous errors)
|
||||||
|
echo -e "${YELLOW}Updating package lists...${NC}"
|
||||||
|
sudo apt update || echo -e "${YELLOW}Warning: apt update had some errors, but continuing...${NC}"
|
||||||
|
|
||||||
|
# Install Nala if not already installed
|
||||||
|
echo -e "${YELLOW}Checking for Nala package manager...${NC}"
|
||||||
|
if ! command -v nala &> /dev/null; then
|
||||||
|
echo -e "${YELLOW}Installing Nala package manager...${NC}"
|
||||||
|
if sudo apt-get install -y nala; then
|
||||||
|
echo -e "${GREEN}Nala installed successfully!${NC}"
|
||||||
|
# Update PKG_MANAGER since we now have nala
|
||||||
|
PKG_MANAGER="nala"
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}Failed to install Nala. Continuing with standard apt...${NC}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -e "${GREEN}Nala is already installed!${NC}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Setup VS Code repository
|
# Determine which package manager to use
|
||||||
echo -e "${YELLOW}Setting up VS Code repository...${NC}"
|
PKG_MANAGER=$(determine_pkg_manager)
|
||||||
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /tmp/packages.microsoft.gpg
|
echo -e "${GREEN}Using package manager: $PKG_MANAGER${NC}"
|
||||||
sudo install -D -o root -g root -m 644 /tmp/packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
|
|
||||||
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
|
|
||||||
rm /tmp/packages.microsoft.gpg
|
|
||||||
|
|
||||||
# Setup GitHub CLI repository
|
# Load packages from package list
|
||||||
echo -e "${YELLOW}Setting up GitHub CLI repository...${NC}"
|
mapfile -t pkgs < <(grep -v '^//' "$SCRIPT_DIR/packages.list" | grep -v -e '^$')
|
||||||
sudo mkdir -p -m 755 /etc/apt/keyrings
|
|
||||||
out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
|
|
||||||
&& sudo install -D -o root -g root -m 644 "$out" /etc/apt/keyrings/githubcli-archive-keyring.gpg \
|
|
||||||
&& rm "$out" \
|
|
||||||
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
|
|
||||||
|
|
||||||
# Initialize USING_NALA variable
|
# Map Debian/Ubuntu package names to Fedora equivalents if needed
|
||||||
USING_NALA=false
|
declare -A fedora_pkg_map
|
||||||
|
fedora_pkg_map["bat"]="bat"
|
||||||
|
fedora_pkg_map["fd-find"]="fd-find"
|
||||||
|
# Add more package mappings as needed
|
||||||
|
|
||||||
# Update package lists (ignoring previous errors)
|
# Process the package list based on OS
|
||||||
echo -e "${YELLOW}Updating package lists...${NC}"
|
install_pkg_list=()
|
||||||
sudo apt update || echo -e "${YELLOW}Warning: apt update had some errors, but continuing...${NC}"
|
for pkg in "${pkgs[@]}"; do
|
||||||
|
# Skip nala package on non-Debian/Ubuntu systems
|
||||||
|
if [ "$pkg" = "nala" ] && [ "$OS_NAME" != "ubuntu" ] && [ "$OS_NAME" != "debian" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
# Install Nala first
|
# Check if we need to map the package name for Fedora
|
||||||
echo -e "${YELLOW}Installing Nala package manager...${NC}"
|
if [ "$OS_NAME" = "fedora" ] && [[ -n "${fedora_pkg_map[$pkg]}" ]]; then
|
||||||
if sudo apt-get install -y nala; then
|
install_pkg_list+=("${fedora_pkg_map[$pkg]}")
|
||||||
USING_NALA=true
|
else
|
||||||
echo -e "${GREEN}Nala installed successfully!${NC}"
|
install_pkg_list+=("$pkg")
|
||||||
else
|
fi
|
||||||
echo -e "${YELLOW}Failed to install Nala. Continuing with standard apt...${NC}"
|
done
|
||||||
fi
|
|
||||||
|
|
||||||
# Configure Nala mirrors and install packages
|
# Install packages using the determined package manager
|
||||||
if [ "$USING_NALA" = true ]; then
|
echo -e "${YELLOW}Installing packages from packages.list with $PKG_MANAGER...${NC}"
|
||||||
echo -e "${YELLOW}Configuring Nala mirrors...${NC}"
|
|
||||||
|
case $PKG_MANAGER in
|
||||||
# First, remove any existing nala sources list to avoid issues with invalid mirrors
|
nala)
|
||||||
sudo rm -f /etc/apt/sources.list.d/nala-sources.list 2>/dev/null
|
# Configure Nala mirrors
|
||||||
|
echo -e "${YELLOW}Configuring Nala mirrors...${NC}"
|
||||||
# Try to fetch mirrors with less aggressive settings
|
# First, remove any existing nala sources list to avoid issues with invalid mirrors
|
||||||
if ! sudo nala fetch --auto --fetches 1 --country auto; then
|
|
||||||
echo -e "${YELLOW}Mirror selection failed, continuing with system default mirrors...${NC}"
|
|
||||||
# Remove any potentially corrupted Nala sources
|
|
||||||
sudo rm -f /etc/apt/sources.list.d/nala-sources.list 2>/dev/null
|
sudo rm -f /etc/apt/sources.list.d/nala-sources.list 2>/dev/null
|
||||||
fi
|
|
||||||
|
# Try to fetch mirrors with less aggressive settings
|
||||||
# Install remaining packages using Nala
|
if ! sudo nala fetch --auto --fetches 1 --country auto; then
|
||||||
echo -e "${YELLOW}Installing packages from packages.list with Nala...${NC}"
|
echo -e "${YELLOW}Mirror selection failed, continuing with system default mirrors...${NC}"
|
||||||
mapfile -t pkgs < <(grep -v '^//' "$SCRIPT_DIR/packages.list" | grep -v -e '^$' -e '^nala$')
|
# Remove any potentially corrupted Nala sources
|
||||||
sudo nala install -y "${pkgs[@]}" || {
|
sudo rm -f /etc/apt/sources.list.d/nala-sources.list 2>/dev/null
|
||||||
echo -e "${YELLOW}Nala install failed, falling back to apt...${NC}"
|
fi
|
||||||
sudo apt-get install -y "${pkgs[@]}"
|
|
||||||
}
|
# Install packages using Nala
|
||||||
else
|
sudo nala install -y "${install_pkg_list[@]}" || {
|
||||||
# Fall back to apt if Nala installation failed
|
echo -e "${YELLOW}Nala install failed, falling back to apt...${NC}"
|
||||||
echo -e "${YELLOW}Installing packages from packages.list with apt...${NC}"
|
sudo apt-get install -y "${install_pkg_list[@]}"
|
||||||
mapfile -t pkgs < <(grep -v '^//' "$SCRIPT_DIR/packages.list" | grep -v -e '^$' -e '^nala$')
|
}
|
||||||
sudo apt-get install -y "${pkgs[@]}"
|
;;
|
||||||
fi
|
dnf)
|
||||||
|
# Install packages using DNF
|
||||||
|
sudo dnf install -y "${install_pkg_list[@]}"
|
||||||
|
;;
|
||||||
|
apt)
|
||||||
|
# Install packages using APT
|
||||||
|
sudo apt-get install -y "${install_pkg_list[@]}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo -e "${GREEN}Package installation completed for $OS_NAME $OS_VERSION.${NC}"
|
||||||
|
|
||||||
# Install Zsh if not already installed
|
# Install Zsh if not already installed
|
||||||
echo -e "${YELLOW}Installing Zsh...${NC}"
|
echo -e "${YELLOW}Installing Zsh...${NC}"
|
||||||
if ! command -v zsh &> /dev/null; then
|
if ! command -v zsh &> /dev/null; then
|
||||||
sudo apt-get install -y zsh
|
case $PKG_MANAGER in
|
||||||
|
nala)
|
||||||
|
sudo nala install -y zsh
|
||||||
|
;;
|
||||||
|
dnf)
|
||||||
|
sudo dnf install -y zsh
|
||||||
|
;;
|
||||||
|
apt)
|
||||||
|
sudo apt-get install -y zsh
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install Oh My Zsh
|
# Install Oh My Zsh
|
||||||
@@ -119,7 +217,7 @@ fi
|
|||||||
echo -e "${YELLOW}Installing zoxide...${NC}"
|
echo -e "${YELLOW}Installing zoxide...${NC}"
|
||||||
if ! command -v zoxide &> /dev/null; then
|
if ! command -v zoxide &> /dev/null; then
|
||||||
curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash
|
curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash
|
||||||
|
|
||||||
# Ensure .local/bin is in PATH
|
# Ensure .local/bin is in PATH
|
||||||
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
|
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
|
||||||
echo 'export PATH="$PATH:$HOME/.local/bin"' >> "$HOME/.bashrc"
|
echo 'export PATH="$PATH:$HOME/.local/bin"' >> "$HOME/.bashrc"
|
||||||
@@ -163,43 +261,53 @@ else
|
|||||||
echo -e "Lazydocker is already installed"
|
echo -e "Lazydocker is already installed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install Zsh plugins
|
# Define a reusable function for cloning Zsh plugins
|
||||||
|
clone_zsh_plugin() {
|
||||||
|
local plugin_url=$1
|
||||||
|
local plugin_dir=$2
|
||||||
|
|
||||||
|
if [ ! -d "$plugin_dir" ]; then
|
||||||
|
git clone "$plugin_url" "$plugin_dir"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install Zsh plugins using the reusable function
|
||||||
echo -e "${YELLOW}Installing Zsh plugins...${NC}"
|
echo -e "${YELLOW}Installing Zsh plugins...${NC}"
|
||||||
ZSH_CUSTOM="$HOME/.oh-my-zsh/custom"
|
ZSH_CUSTOM="$HOME/.oh-my-zsh/custom"
|
||||||
PLUGINS_DIR="$ZSH_CUSTOM/plugins"
|
PLUGINS_DIR="$ZSH_CUSTOM/plugins"
|
||||||
|
clone_zsh_plugin "https://github.com/zsh-users/zsh-autosuggestions" "$PLUGINS_DIR/zsh-autosuggestions"
|
||||||
# zsh-autosuggestions
|
clone_zsh_plugin "https://github.com/zsh-users/zsh-syntax-highlighting" "$PLUGINS_DIR/zsh-syntax-highlighting"
|
||||||
if [ ! -d "$PLUGINS_DIR/zsh-autosuggestions" ]; then
|
clone_zsh_plugin "https://github.com/MichaelAquilina/zsh-you-should-use" "$PLUGINS_DIR/zsh-you-should-use"
|
||||||
git clone https://github.com/zsh-users/zsh-autosuggestions "$PLUGINS_DIR/zsh-autosuggestions"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# zsh-syntax-highlighting
|
|
||||||
if [ ! -d "$PLUGINS_DIR/zsh-syntax-highlighting" ]; then
|
|
||||||
git clone https://github.com/zsh-users/zsh-syntax-highlighting "$PLUGINS_DIR/zsh-syntax-highlighting"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# zsh-you-should-use
|
|
||||||
if [ ! -d "$PLUGINS_DIR/zsh-you-should-use" ]; then
|
|
||||||
git clone https://github.com/MichaelAquilina/zsh-you-should-use "$PLUGINS_DIR/zsh-you-should-use"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set up dotfiles
|
# Set up dotfiles
|
||||||
echo -e "${YELLOW}Setting up dotfiles...${NC}"
|
echo -e "${YELLOW}Setting up dotfiles...${NC}"
|
||||||
# Set up Oh My Zsh custom directory and aliases
|
# Consolidate symbolic link creation for dotfiles
|
||||||
ZSH_CUSTOM="$HOME/.oh-my-zsh/custom"
|
|
||||||
mkdir -p "$ZSH_CUSTOM"
|
|
||||||
ln -sf "$DOTFILES_SUBDIR/my-aliases.zsh" "$ZSH_CUSTOM/aliases.zsh"
|
|
||||||
|
|
||||||
# Set up dotfiles in home directory
|
|
||||||
ln -sf "$DOTFILES_SUBDIR/.zshrc" "$HOME/.zshrc"
|
ln -sf "$DOTFILES_SUBDIR/.zshrc" "$HOME/.zshrc"
|
||||||
ln -sf "$DOTFILES_SUBDIR/.nanorc" "$HOME/.nanorc" 2>/dev/null || true
|
ln -sf "$DOTFILES_SUBDIR/.nanorc" "$HOME/.nanorc" 2>/dev/null || true
|
||||||
ln -sf "$DOTFILES_SUBDIR/.profile" "$HOME/.profile" 2>/dev/null || true
|
ln -sf "$DOTFILES_SUBDIR/.profile" "$HOME/.profile" 2>/dev/null || true
|
||||||
ln -sf "$DOTFILES_SUBDIR/.gitconfig" "$HOME/.gitconfig" 2>/dev/null || true
|
ln -sf "$DOTFILES_SUBDIR/.gitconfig" "$HOME/.gitconfig" 2>/dev/null || true
|
||||||
|
|
||||||
|
if [ "$OS_NAME" = "fedora" ]; then
|
||||||
|
echo -e "${YELLOW}Setting up Fedora-specific configurations...${NC}"
|
||||||
|
echo -e "${GREEN}Fedora-specific setup completed.${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
# Set Zsh as default shell if not already set
|
# Set Zsh as default shell if not already set
|
||||||
if [[ "$SHELL" != *"zsh"* ]]; then
|
if [[ "$SHELL" != *"zsh"* ]]; then
|
||||||
echo -e "${YELLOW}Setting Zsh as default shell...${NC}"
|
echo -e "${YELLOW}Setting Zsh as default shell...${NC}"
|
||||||
chsh -s $(which zsh)
|
ZSH_PATH=$(which zsh)
|
||||||
|
if [ -f "$ZSH_PATH" ]; then
|
||||||
|
# Check if zsh is already in /etc/shells
|
||||||
|
if ! grep -q "$ZSH_PATH" /etc/shells; then
|
||||||
|
echo -e "${YELLOW}Adding $ZSH_PATH to /etc/shells...${NC}"
|
||||||
|
echo "$ZSH_PATH" | sudo tee -a /etc/shells
|
||||||
|
fi
|
||||||
|
# Set as default shell
|
||||||
|
chsh -s "$ZSH_PATH"
|
||||||
|
else
|
||||||
|
echo -e "${RED}Zsh not found at $ZSH_PATH. Please set it as your default shell manually.${NC}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "${GREEN}Setup completed successfully!${NC}"
|
echo -e "${GREEN}Setup completed successfully for $OS_NAME $OS_VERSION!${NC}"
|
||||||
|
echo -e "${YELLOW}Note: You may need to log out and log back in for all changes to take effect.${NC}"
|
||||||
|
|||||||
51
update.sh
51
update.sh
@@ -1,5 +1,34 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Colors for output
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[0;33m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
# Detect OS
|
||||||
|
if [ -f /etc/os-release ]; then
|
||||||
|
. /etc/os-release
|
||||||
|
OS_NAME=$ID
|
||||||
|
OS_VERSION=$VERSION_ID
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}Unable to detect OS, assuming Debian/Ubuntu...${NC}"
|
||||||
|
OS_NAME="ubuntu"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Function to determine the package manager to use
|
||||||
|
determine_pkg_manager() {
|
||||||
|
if command -v nala &> /dev/null; then
|
||||||
|
echo "nala"
|
||||||
|
elif [ "$OS_NAME" = "fedora" ]; then
|
||||||
|
echo "dnf"
|
||||||
|
else
|
||||||
|
echo "apt"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
PKG_MANAGER=$(determine_pkg_manager)
|
||||||
|
echo -e "${GREEN}Using package manager: $PKG_MANAGER${NC}"
|
||||||
|
|
||||||
# checks if the plexmediaserver.service is defined on this machine. stop it if it is.
|
# checks if the plexmediaserver.service is defined on this machine. stop it if it is.
|
||||||
if systemctl is-active --quiet plexmediaserver.service 2>/dev/null; then
|
if systemctl is-active --quiet plexmediaserver.service 2>/dev/null; then
|
||||||
sudo /home/acedanger/shell/plex.sh stop
|
sudo /home/acedanger/shell/plex.sh stop
|
||||||
@@ -9,12 +38,28 @@ omz_upgrade_script=~/.oh-my-zsh/tools/upgrade.sh
|
|||||||
|
|
||||||
# Check if the script exists and is executable
|
# Check if the script exists and is executable
|
||||||
if [ -x "$omz_upgrade_script" ]; then
|
if [ -x "$omz_upgrade_script" ]; then
|
||||||
echo "Attempting Oh My Zsh upgrade..."
|
echo -e "${YELLOW}Attempting Oh My Zsh upgrade...${NC}"
|
||||||
"$omz_upgrade_script"
|
"$omz_upgrade_script"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo nala update
|
# Update packages using the appropriate package manager
|
||||||
sudo nala upgrade -y
|
case $PKG_MANAGER in
|
||||||
|
nala)
|
||||||
|
echo -e "${GREEN}Updating system using nala...${NC}"
|
||||||
|
sudo nala update
|
||||||
|
sudo nala upgrade -y
|
||||||
|
;;
|
||||||
|
dnf)
|
||||||
|
echo -e "${GREEN}Updating system using dnf...${NC}"
|
||||||
|
sudo dnf check-update -y || true
|
||||||
|
sudo dnf upgrade -y
|
||||||
|
;;
|
||||||
|
apt)
|
||||||
|
echo -e "${GREEN}Updating system using apt...${NC}"
|
||||||
|
sudo apt update
|
||||||
|
sudo apt upgrade -y
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# checks if the plexmediaserver.service is defined on this machine. start it if it is.
|
# checks if the plexmediaserver.service is defined on this machine. start it if it is.
|
||||||
if systemctl is-enabled --quiet plexmediaserver.service 2>/dev/null; then
|
if systemctl is-enabled --quiet plexmediaserver.service 2>/dev/null; then
|
||||||
|
|||||||
Reference in New Issue
Block a user