Upload files to "/"
This commit is contained in:
93
.zshrc
Normal file
93
.zshrc
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
# ─── Ensure Ruby Gem Binaries Are in PATH ──────────────────────────────
|
||||||
|
# Handles all Ruby versions for user-installed gems like colorls
|
||||||
|
setopt nullglob
|
||||||
|
for dir in "$HOME/.gem/ruby/"*/bin ; do
|
||||||
|
[[ -d $dir ]] && PATH="$PATH:$dir"
|
||||||
|
done
|
||||||
|
export PATH
|
||||||
|
|
||||||
|
#Root
|
||||||
|
sudo() {
|
||||||
|
if [[ "$1" == "nano" ]]; then
|
||||||
|
TERM=xterm command sudo nano "${@:2}"
|
||||||
|
else
|
||||||
|
command sudo "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# ─── Powerlevel10k Instant Prompt (Should stay close to the top) ───────
|
||||||
|
typeset -g POWERLEVEL9K_INSTANT_PROMPT=off
|
||||||
|
autoload -Uz compinit
|
||||||
|
compinit
|
||||||
|
|
||||||
|
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
||||||
|
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ─── Oh My Zsh and Theme Setup ────────────────────────────────────────
|
||||||
|
export ZSH="$HOME/.oh-my-zsh"
|
||||||
|
ZSH_THEME="powerlevel10k/powerlevel10k"
|
||||||
|
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
||||||
|
|
||||||
|
# ─── Plugins ──────────────────────────────────────────────────────────
|
||||||
|
plugins=(git zsh-autosuggestions zsh-syntax-highlighting zsh-completions)
|
||||||
|
source $ZSH/oh-my-zsh.sh
|
||||||
|
|
||||||
|
# ─── Aliases: Use colorls If Available, Fallback to ls ────────────────
|
||||||
|
if command -v colorls >/dev/null 2>&1; then
|
||||||
|
alias ls='colorls -d'
|
||||||
|
alias ll='colorls -l'
|
||||||
|
alias la='colorls -a'
|
||||||
|
alias sls='colorls'
|
||||||
|
else
|
||||||
|
alias ls='ls --color=auto'
|
||||||
|
alias ll='ls -l --color=auto'
|
||||||
|
alias la='ls -a --color=auto'
|
||||||
|
alias sls='ls'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ─── User Aliases and Functions ───────────────────────────────────────
|
||||||
|
alias up="/home/$USER/Homelab/up.sh"
|
||||||
|
alias pup="/home/$USER/Homelab/portainerup.sh"
|
||||||
|
alias p10="p10k configure"
|
||||||
|
alias fresh='source ~/.zshrc'
|
||||||
|
alias clear='clear && source ~/.zshrc'
|
||||||
|
alias portainerup='bash /home/$USER/Homelab/portainerup.sh'
|
||||||
|
alias nano='TERM=xterm nano'
|
||||||
|
alias ali='grep '^alias' ~/.zshrc'
|
||||||
|
|
||||||
|
# ─── Welcome Message and HomeDir Listing ──────────────────────────────
|
||||||
|
echo "┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐"
|
||||||
|
echo "| \x1b[32mWelcome Back My Master\x1b[0m |"
|
||||||
|
echo "└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘"
|
||||||
|
echo ""
|
||||||
|
fastfetch
|
||||||
|
echo ""
|
||||||
|
echo "┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐"
|
||||||
|
echo "| \x1b[32mEnjoy, here is your HomeDir\x1b[0m |"
|
||||||
|
echo "└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘"
|
||||||
|
echo " ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── "
|
||||||
|
sls
|
||||||
|
echo " ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── "
|
||||||
|
|
||||||
|
# ─── Optional: Additional User Configuration ──────────────────────────
|
||||||
|
# export LANG=en_US.UTF-8
|
||||||
|
# export EDITOR='nvim'
|
||||||
|
# export MANPATH="/usr/local/man:$MANPATH"
|
||||||
|
# export ARCHFLAGS="-arch $(uname -m)"
|
||||||
|
# ZSH_CUSTOM=/path/to/new-custom-folder
|
||||||
|
# HIST_STAMPS="mm/dd/yyyy"
|
||||||
|
# zstyle ':omz:update' mode auto
|
||||||
|
# zstyle ':omz:update' frequency 13
|
||||||
|
|
||||||
|
# End of .zshrc
|
||||||
|
export EDITOR="nano"
|
||||||
|
export VISUAL="nano"
|
||||||
|
|
||||||
|
|
||||||
|
## [Completion]
|
||||||
|
## Completion scripts setup. Remove the following line to uninstall
|
||||||
|
[[ -f /home/stiannor/.dart-cli-completion/zsh-config.zsh ]] && . /home/stiannor/.dart-cli-completion/zsh-config.zsh || true
|
||||||
|
## [/Completion]
|
||||||
|
|
||||||
168
font_nerd_hack.sh
Normal file
168
font_nerd_hack.sh
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Detect Linux distro name from /etc/os-release
|
||||||
|
get_distro() {
|
||||||
|
if [[ -f /etc/os-release ]]; then
|
||||||
|
source /etc/os-release
|
||||||
|
echo "$NAME"
|
||||||
|
else
|
||||||
|
uname -s
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Detect Desktop environment (lowercase)
|
||||||
|
get_desktop_env() {
|
||||||
|
local de=${XDG_CURRENT_DESKTOP,,}
|
||||||
|
if [[ -z "$de" ]]; then
|
||||||
|
de=${DESKTOP_SESSION,,}
|
||||||
|
fi
|
||||||
|
echo "$de"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Detect terminal emulator(s) from environment or common process names
|
||||||
|
get_terminals() {
|
||||||
|
local terms=()
|
||||||
|
# Check $TERM_PROGRAM or common terminal process names
|
||||||
|
# Add more terminals if needed
|
||||||
|
for t in gnome-terminal konsole alacritty kitty xfce4-terminal mate-terminal; do
|
||||||
|
if pgrep -x "$t" > /dev/null 2>&1; then
|
||||||
|
terms+=("$t")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "${terms[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
DISTRO_NAME=$(get_distro)
|
||||||
|
DESKTOP_ENV=$(get_desktop_env)
|
||||||
|
TERMINALS=$(get_terminals)
|
||||||
|
|
||||||
|
# Fonts and sizes
|
||||||
|
FONT_ALIAS="Hack Nerd Font"
|
||||||
|
GENERAL_FONT_SIZE="12"
|
||||||
|
FIXED_FONT_SIZE="10"
|
||||||
|
SMALL_FONT_SIZE="8"
|
||||||
|
OTHER_FONT_SIZE="10"
|
||||||
|
|
||||||
|
# Download and install Hack Nerd Font system-wide
|
||||||
|
TMPDIR=$(mktemp -d)
|
||||||
|
wget -O "$TMPDIR/Hack.zip" https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/Hack.zip
|
||||||
|
unzip "$TMPDIR/Hack.zip" -d "$TMPDIR/Hack"
|
||||||
|
sudo mkdir -p /usr/local/share/fonts/nerd-fonts
|
||||||
|
sudo mv "$TMPDIR/Hack/"*.ttf "$TMPDIR/Hack/"*.otf /usr/local/share/fonts/nerd-fonts/
|
||||||
|
sudo fc-cache -fv
|
||||||
|
|
||||||
|
# Apply fonts for Desktop Environments
|
||||||
|
|
||||||
|
case "$DESKTOP_ENV" in
|
||||||
|
*kde*)
|
||||||
|
if command -v kwriteconfig5 &>/dev/null; then
|
||||||
|
kwriteconfig5 --file kdeglobals --group General --key font "$FONT_ALIAS,$GENERAL_FONT_SIZE,-1,5,50,0,0,0,0,0"
|
||||||
|
kwriteconfig5 --file kdeglobals --group Fixed --key font "$FONT_ALIAS,$FIXED_FONT_SIZE,-1,5,50,0,0,0,0,0"
|
||||||
|
kwriteconfig5 --file kdeglobals --group Small --key font "$FONT_ALIAS,$SMALL_FONT_SIZE,-1,5,50,0,0,0,0,0"
|
||||||
|
kwriteconfig5 --file kdeglobals --group Toolbar --key font "$FONT_ALIAS,$OTHER_FONT_SIZE,-1,5,50,0,0,0,0,0"
|
||||||
|
kwriteconfig5 --file kdeglobals --group Menu --key font "$FONT_ALIAS,$OTHER_FONT_SIZE,-1,5,50,0,0,0,0,0"
|
||||||
|
kwriteconfig5 --file kdeglobals --group "Window Title" --key font "$FONT_ALIAS,$OTHER_FONT_SIZE,-1,5,50,0,0,0,0,0"
|
||||||
|
kwriteconfig5 --file kdeglobals --group General --key antialiasing "true"
|
||||||
|
kwriteconfig5 --file kdeglobals --group General --key hinting "slight"
|
||||||
|
kwriteconfig5 --file kdeglobals --group General --key subpixelRendering "rgb"
|
||||||
|
kwriteconfig5 --file kdeglobals --group General --key forceFontDpi 96
|
||||||
|
fi
|
||||||
|
# KDE Konsole font in all profiles
|
||||||
|
find ~/.local/share/konsole -name "*.profile" -exec sed -i "s/^Font=.*/Font=$FONT_ALIAS $GENERAL_FONT_SIZE/" {} \;
|
||||||
|
;;
|
||||||
|
*gnome*|*cinnamon*)
|
||||||
|
if command -v gsettings &>/dev/null; then
|
||||||
|
gsettings set org.gnome.desktop.interface font-name "$FONT_ALIAS $GENERAL_FONT_SIZE"
|
||||||
|
gsettings set org.gnome.desktop.interface monospace-font-name "$FONT_ALIAS $FIXED_FONT_SIZE"
|
||||||
|
if [[ "$DESKTOP_ENV" == *gnome* ]] && command -v dconf &>/dev/null; then
|
||||||
|
for profile in $(dconf list /org/gnome/terminal/legacy/profiles:/ | grep -oP '[^/]+' | sort | uniq); do
|
||||||
|
dconf write "/org/gnome/terminal/legacy/profiles:/:$profile/font" "'$FONT_ALIAS $FIXED_FONT_SIZE'"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*xfce*)
|
||||||
|
xfconf-query -c xsettings -p /Gtk/FontName -s "$FONT_ALIAS $GENERAL_FONT_SIZE"
|
||||||
|
xfconf-query -c xfwm4 -p /general/font -s "$FONT_ALIAS $GENERAL_FONT_SIZE"
|
||||||
|
xfce_term_conf="$HOME/.config/xfce4/terminal/terminalrc"
|
||||||
|
if [ -f "$xfce_term_conf" ]; then
|
||||||
|
sed -i "s/^FontName=.*/FontName=$FONT_ALIAS $FIXED_FONT_SIZE/" "$xfce_term_conf"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*mate*)
|
||||||
|
if command -v gsettings &>/dev/null; then
|
||||||
|
gsettings set org.mate.interface font-name "$FONT_ALIAS $GENERAL_FONT_SIZE"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# Generic fallback for desktops not specifically recognized
|
||||||
|
echo "Unknown or unsupported desktop $DESKTOP_ENV, font set might be partial."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Apply fonts for terminal emulators detected
|
||||||
|
|
||||||
|
for term in $TERMINALS; do
|
||||||
|
case $term in
|
||||||
|
gnome-terminal)
|
||||||
|
# Already handled via dconf in GNOME case
|
||||||
|
;;
|
||||||
|
konsole)
|
||||||
|
find ~/.local/share/konsole -name "*.profile" -exec sed -i "s/^Font=.*/Font=$FONT_ALIAS $GENERAL_FONT_SIZE/" {} \;
|
||||||
|
;;
|
||||||
|
alacritty)
|
||||||
|
alacritty_conf="$HOME/.config/alacritty/alacritty.yml"
|
||||||
|
if [ -f "$alacritty_conf" ]; then
|
||||||
|
sed -i "/^ *family:/c\ family: \"$FONT_ALIAS\"" "$alacritty_conf"
|
||||||
|
sed -i "/^ *size:/c\ size: $GENERAL_FONT_SIZE" "$alacritty_conf"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
kitty)
|
||||||
|
kitty_conf="$HOME/.config/kitty/kitty.conf"
|
||||||
|
if [ -f "$kitty_conf" ]; then
|
||||||
|
sed -i "/^font_family/c\font_family $FONT_ALIAS" "$kitty_conf"
|
||||||
|
sed -i "/^font_size/c\font_size $GENERAL_FONT_SIZE" "$kitty_conf"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
xfce4-terminal)
|
||||||
|
xfce_term_conf="$HOME/.config/xfce4/terminal/terminalrc"
|
||||||
|
if [ -f "$xfce_term_conf" ]; then
|
||||||
|
sed -i "s/^FontName=.*/FontName=$FONT_ALIAS $FIXED_FONT_SIZE/" "$xfce_term_conf"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
mate-terminal)
|
||||||
|
# Mate terminal config editing would be needed here if required
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Set console (TTY) font (supports bitmap fonts - approximate)
|
||||||
|
if grep -q "FONT=" /etc/vconsole.conf; then
|
||||||
|
sudo sed -i "s/^FONT=.*/FONT=\"$FONT_ALIAS-Regular\"/" /etc/vconsole.conf
|
||||||
|
else
|
||||||
|
echo "FONT=\"$FONT_ALIAS-Regular\"" | sudo tee -a /etc/vconsole.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Global fontconfig fallback for monospace font
|
||||||
|
sudo tee /etc/fonts/local.conf > /dev/null <<EOF
|
||||||
|
<?xml version='1.0'?>
|
||||||
|
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
||||||
|
<fontconfig>
|
||||||
|
<alias>
|
||||||
|
<family>monospace</family>
|
||||||
|
<prefer>
|
||||||
|
<family>$FONT_ALIAS</family>
|
||||||
|
</prefer>
|
||||||
|
</alias>
|
||||||
|
</fontconfig>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
rm -rf "$TMPDIR"
|
||||||
|
|
||||||
|
desktop_msg="${DESKTOP_ENV^}"
|
||||||
|
terminal_list=$(echo $TERMINALS | tr ' ' ', ')
|
||||||
|
|
||||||
|
echo "Hack Nerd Font installed."
|
||||||
|
echo "Applied to desktop environment: $desktop_msg."
|
||||||
|
echo "Applied to terminal(s): $terminal_list."
|
||||||
|
echo "Please restart your desktop session or reboot to ensure complete font application."
|
||||||
85
portainer_docker_uninstall.sh
Normal file
85
portainer_docker_uninstall.sh
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
# --- Colors and Formatting ---
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
BLUE='\033[0;34m'
|
||||||
|
CYAN='\033[0;36m'
|
||||||
|
BOLD='\033[1m'
|
||||||
|
RESET='\033[0m'
|
||||||
|
info() { echo -e "${CYAN}ℹ️ $*${RESET}"; }
|
||||||
|
success() { echo -e "${GREEN}✅ $*${RESET}"; }
|
||||||
|
warn() { echo -e "${YELLOW}⚠️ $*${RESET}"; }
|
||||||
|
error() { echo -e "${RED}❌ $*${RESET}"; }
|
||||||
|
step() { echo -e "${BOLD}${BLUE}➤ $*${RESET}"; }
|
||||||
|
|
||||||
|
# Require sudo upfront
|
||||||
|
if ! sudo -v; then
|
||||||
|
error "This script requires sudo privileges. Please run again with a sudo-capable user."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
step "Stopping Docker and Portainer containers/services..."
|
||||||
|
|
||||||
|
# Stop Portainer container if running
|
||||||
|
if docker ps -a --format '{{.Names}}' | grep -q "^portainer$"; then
|
||||||
|
info "Stopping Portainer container..."
|
||||||
|
sudo docker stop portainer || true
|
||||||
|
sudo docker rm portainer || true
|
||||||
|
else
|
||||||
|
info "Portainer container not found."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Stop Docker service
|
||||||
|
info "Stopping Docker service..."
|
||||||
|
sudo systemctl stop docker || true
|
||||||
|
|
||||||
|
step "Removing Docker packages..."
|
||||||
|
|
||||||
|
# Detect distro to remove packages accordingly
|
||||||
|
if [ -f /etc/os-release ]; then
|
||||||
|
. /etc/os-release
|
||||||
|
DISTRO_ID="$ID"
|
||||||
|
else
|
||||||
|
DISTRO_ID=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$DISTRO_ID" in
|
||||||
|
ubuntu|debian|raspbian|linuxmint)
|
||||||
|
sudo apt-get purge -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker
|
||||||
|
sudo apt-get autoremove -y --purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker
|
||||||
|
;;
|
||||||
|
fedora)
|
||||||
|
sudo dnf remove -y moby-engine docker-cli containerd docker-buildx docker-compose docker-compose-switch || true
|
||||||
|
;;
|
||||||
|
centos|rhel|rocky|almalinux|ol|oracle)
|
||||||
|
sudo yum remove -y docker-ce docker-ce-cli containerd.io docker-compose-plugin || true
|
||||||
|
;;
|
||||||
|
arch|manjaro|endeavouros|garuda|artix|arcolinux|antergos|chakra|kaos)
|
||||||
|
sudo pacman -Rns --noconfirm docker docker-compose
|
||||||
|
;;
|
||||||
|
opensuse*|suse|sles)
|
||||||
|
sudo zypper remove -y docker docker-compose
|
||||||
|
;;
|
||||||
|
alpine)
|
||||||
|
sudo apk del docker docker-compose
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
warn "Unsupported or unrecognized Linux distribution: $DISTRO_ID - skipping package removal"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
step "Removing Docker data and configuration files..."
|
||||||
|
|
||||||
|
# Remove Docker directories and leftover files
|
||||||
|
sudo rm -rf /var/lib/docker /var/lib/containerd /etc/docker /etc/systemd/system/docker.service.d
|
||||||
|
sudo rm -rf ~/.docker
|
||||||
|
|
||||||
|
# Remove Docker group and socket if exist
|
||||||
|
sudo groupdel docker || true
|
||||||
|
sudo rm -f /var/run/docker.sock || true
|
||||||
|
|
||||||
|
step "Clean up completed."
|
||||||
|
|
||||||
|
success "Docker and Portainer have been uninstalled from this system."
|
||||||
228
portainerup.sh
Normal file
228
portainerup.sh
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# --- Colors and Formatting ---
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
BLUE='\033[0;34m'
|
||||||
|
CYAN='\033[0;36m'
|
||||||
|
BOLD='\033[1m'
|
||||||
|
RESET='\033[0m'
|
||||||
|
|
||||||
|
info() { echo -e "${CYAN}ℹ $*${RESET}"; }
|
||||||
|
success() { echo -e "${GREEN}✅ $*${RESET}"; }
|
||||||
|
warn() { echo -e "${YELLOW}⚠ $*${RESET}"; }
|
||||||
|
error() { echo -e "${RED}❌ $*${RESET}"; }
|
||||||
|
step() { echo -e "${BOLD}${BLUE}➤ $*${RESET}"; }
|
||||||
|
|
||||||
|
# Prompt for sudo password upfront, so it caches for script duration
|
||||||
|
if ! sudo -v; then
|
||||||
|
error "This script requires sudo privileges. Please run again with a sudo-capable user."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Keep-alive to update sudo timestamp until script finishes
|
||||||
|
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
|
||||||
|
|
||||||
|
# --- Detect distribution ---
|
||||||
|
if [ -f /etc/os-release ]; then
|
||||||
|
. /etc/os-release
|
||||||
|
DISTRO_ID="$ID"
|
||||||
|
DISTRO_VERSION="$VERSION_ID"
|
||||||
|
DISTRO_CODENAME="$VERSION_CODENAME"
|
||||||
|
else
|
||||||
|
error "Cannot detect Linux distribution."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fallback for older Debian/Ubuntu releases
|
||||||
|
if [[ "$DISTRO_ID" == "debian" ]]; then
|
||||||
|
if [[ -z "$DISTRO_CODENAME" || ! -f "/usr/share/keyrings/docker-archive-keyring.gpg" ]]; then
|
||||||
|
DISTRO_CODENAME="bookworm" # Fallback to Debian 12
|
||||||
|
fi
|
||||||
|
elif [[ "$DISTRO_ID" == "ubuntu" ]]; then
|
||||||
|
if [[ -z "$DISTRO_CODENAME" || ! -f "/usr/share/keyrings/docker-archive-keyring.gpg" ]]; then
|
||||||
|
DISTRO_CODENAME="jammy" # Fallback to Ubuntu 22.04 LTS
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
install_docker() {
|
||||||
|
step "Installing Docker for ${BOLD}$DISTRO_ID $DISTRO_VERSION${RESET}..."
|
||||||
|
|
||||||
|
case "$DISTRO_ID" in
|
||||||
|
ubuntu|debian|raspbian|linuxmint)
|
||||||
|
info "Adding Docker repository and installing Docker for Debian/Ubuntu..."
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install -y apt-transport-https ca-certificates curl gnupg lsb-release
|
||||||
|
curl -fsSL https://download.docker.com/linux/"$DISTRO_ID"/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
||||||
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/$DISTRO_ID $DISTRO_CODENAME stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||||
|
sudo systemctl enable --now docker
|
||||||
|
;;
|
||||||
|
|
||||||
|
fedora)
|
||||||
|
info "Installing Docker from Fedora repositories..."
|
||||||
|
sudo dnf remove -y podman-docker || true
|
||||||
|
sudo dnf install -y dnf-plugins-core
|
||||||
|
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
|
||||||
|
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||||
|
sudo systemctl enable --now docker
|
||||||
|
;;
|
||||||
|
|
||||||
|
centos|rhel|rocky|almalinux|ol|oracle)
|
||||||
|
info "Adding Docker repository and installing Docker for CentOS/RHEL..."
|
||||||
|
sudo yum install -y yum-utils
|
||||||
|
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
||||||
|
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||||
|
sudo systemctl enable --now docker
|
||||||
|
;;
|
||||||
|
|
||||||
|
arch|manjaro|endeavouros|garuda|artix|arcolinux|antergos|chakra|kaos)
|
||||||
|
info "Installing Docker with pacman (Arch-based)..."
|
||||||
|
sudo pacman -Sy --noconfirm docker docker-compose
|
||||||
|
sudo systemctl enable --now docker
|
||||||
|
;;
|
||||||
|
|
||||||
|
opensuse*|suse|sles)
|
||||||
|
info "Installing Docker with zypper..."
|
||||||
|
sudo zypper install -y docker docker-compose
|
||||||
|
sudo systemctl enable --now docker
|
||||||
|
;;
|
||||||
|
|
||||||
|
alpine)
|
||||||
|
info "Installing Docker with apk..."
|
||||||
|
sudo apk add --update docker docker-compose
|
||||||
|
sudo rc-update add docker boot
|
||||||
|
sudo service docker start
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
error "Unsupported or unrecognized Linux distribution: $DISTRO_ID"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Fix permissions for current user
|
||||||
|
sudo chown -R "$USER":"$USER" "$HOME/.docker" || true
|
||||||
|
sudo chmod -R g+rwx "$HOME/.docker" || true
|
||||||
|
|
||||||
|
if ! groups "$USER" | grep -qw docker; then
|
||||||
|
sudo usermod -aG docker "$USER"
|
||||||
|
warn "User '$USER' has been added to the 'docker' group."
|
||||||
|
error "IMPORTANT: Docker group permissions will NOT be active in this current session."
|
||||||
|
error "Please LOG OUT completely and LOG BACK IN (or reboot the machine) then re-run this script."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
success "User '$USER' is already in the 'docker' group."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
install_docker_compose_standalone() {
|
||||||
|
step "Installing Docker Compose standalone..."
|
||||||
|
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||||
|
sudo chmod +x /usr/local/bin/docker-compose
|
||||||
|
success "Docker Compose installed."
|
||||||
|
}
|
||||||
|
|
||||||
|
step "Checking for Docker..."
|
||||||
|
if ! command -v docker &>/dev/null; then
|
||||||
|
warn "Docker not found. Starting installation..."
|
||||||
|
install_docker
|
||||||
|
else
|
||||||
|
success "Docker is already installed."
|
||||||
|
fi
|
||||||
|
|
||||||
|
step "Verifying Docker daemon access permissions for current user..."
|
||||||
|
if ! docker info &>/dev/null; then
|
||||||
|
error "Permission denied: Cannot connect to Docker daemon."
|
||||||
|
error "Your user ('$USER') does not have correct permissions for Docker in this session."
|
||||||
|
info "Current groups for user: $(groups "$USER")"
|
||||||
|
info "Docker socket permissions: $(ls -l /var/run/docker.sock 2>/dev/null || echo 'Socket not found')"
|
||||||
|
error "Try running this command to refresh group membership in this terminal:"
|
||||||
|
echo -e "${YELLOW} newgrp docker${RESET}"
|
||||||
|
error "Or LOG OUT completely and LOG BACK IN (or reboot the machine) then re-run this script."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
success "Docker daemon is accessible with current user permissions."
|
||||||
|
fi
|
||||||
|
|
||||||
|
step "Checking for Docker Compose..."
|
||||||
|
if ! docker compose version &>/dev/null; then
|
||||||
|
if ! command -v docker-compose &>/dev/null; then
|
||||||
|
warn "Docker Compose not found. Installing standalone version..."
|
||||||
|
install_docker_compose_standalone
|
||||||
|
else
|
||||||
|
success "Docker Compose (standalone) is already installed."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
success "Docker Compose (plugin) is already installed."
|
||||||
|
fi
|
||||||
|
|
||||||
|
step "Ensuring Docker service is running..."
|
||||||
|
if [[ "$DISTRO_ID" == "alpine" ]]; then
|
||||||
|
if ! sudo service docker status 2>/dev/null | grep -q 'status: started'; then
|
||||||
|
info "Starting Docker service..."
|
||||||
|
sudo service docker start || true
|
||||||
|
sleep 5 # Give Docker time to start
|
||||||
|
else
|
||||||
|
success "Docker service is running."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if ! sudo systemctl is-active --quiet docker; then
|
||||||
|
info "Starting Docker service..."
|
||||||
|
sudo systemctl start docker || true
|
||||||
|
sleep 5 # Give Docker time to start
|
||||||
|
else
|
||||||
|
success "Docker service is running."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- Portainer Installation/Update ---
|
||||||
|
UPDATE_PORTAINER=${1:-""}
|
||||||
|
|
||||||
|
step "Checking for existing Portainer container..."
|
||||||
|
if docker ps -a --format '{{.Names}}' | grep -q "^portainer$"; then
|
||||||
|
if [[ "$UPDATE_PORTAINER" == "--update" ]]; then
|
||||||
|
warn "Updating Portainer container..."
|
||||||
|
docker stop portainer || true
|
||||||
|
docker rm portainer || true
|
||||||
|
else
|
||||||
|
warn "Portainer container already exists. Use '--update' to force an update."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
info "No existing Portainer container found. Proceeding with installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
step "Pulling latest Portainer image..."
|
||||||
|
docker pull portainer/portainer-ce:latest
|
||||||
|
|
||||||
|
step "Starting Portainer container..."
|
||||||
|
if [[ "$DISTRO_ID" == "fedora" ]]; then
|
||||||
|
docker run -d \
|
||||||
|
--privileged \
|
||||||
|
-p 8000:8000 -p 9443:9443 \
|
||||||
|
--name portainer \
|
||||||
|
--restart=always \
|
||||||
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||||
|
-v portainer_data:/data \
|
||||||
|
portainer/portainer-ce:latest
|
||||||
|
else
|
||||||
|
docker run -d \
|
||||||
|
-p 8000:8000 -p 9443:9443 \
|
||||||
|
--name portainer \
|
||||||
|
--restart=always \
|
||||||
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||||
|
-v portainer_data:/data \
|
||||||
|
portainer/portainer-ce:latest
|
||||||
|
fi
|
||||||
|
|
||||||
|
success "Portainer is now installed and running!"
|
||||||
|
|
||||||
|
# --- IP Detection ---
|
||||||
|
IP=$(hostname -I 2>/dev/null | awk '{print $1}' || ip route get 1 | awk '{print $7}' || echo "localhost")
|
||||||
|
|
||||||
|
echo -e "${BOLD}${CYAN}🌐 Access your Portainer dashboard at:${RESET} ${GREEN}https://$IP:9443${RESET}"
|
||||||
|
echo -e "${YELLOW}Note: You may need to accept a self-signed certificate in your browser for HTTPS.${RESET}"
|
||||||
Reference in New Issue
Block a user