batman
This commit is contained in:
commit
b49e34c45d
5 changed files with 474 additions and 0 deletions
20
debian/Dockerfile
vendored
Normal file
20
debian/Dockerfile
vendored
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
FROM debian:trixie-slim
|
||||||
|
|
||||||
|
RUN apt update && apt install --assume-yes curl zsh fzf zoxide unzip sudo git make stow
|
||||||
|
|
||||||
|
RUN curl -s https://ohmyposh.dev/install.sh | bash -s -- -d /bin
|
||||||
|
RUN useradd -m -G sudo -r -s /usr/bin/zsh debian
|
||||||
|
|
||||||
|
RUN echo "debian ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
|
||||||
|
USER debian
|
||||||
|
WORKDIR /home/debian
|
||||||
|
COPY ./setupDebian.sh .
|
||||||
|
COPY ./neovim.sh .
|
||||||
|
COPY ./zellij.sh .
|
||||||
|
COPY ./colorscript.sh .
|
||||||
|
|
||||||
|
RUN bash neovim.sh
|
||||||
|
RUN bash zellij.sh
|
||||||
|
RUN bash colorscript.sh
|
||||||
|
|
||||||
|
RUN git clone --recursive --depth=1 https://git.k4li.de/dotfiles/minimal.git /home/pika/dotfiles
|
83
debian/colorscript.sh
vendored
Normal file
83
debian/colorscript.sh
vendored
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# ─< ANSI color codes >───────────────────────────────────────────────────────────────────
|
||||||
|
RED='\033[0;31m'
|
||||||
|
CYAN='\033[0;36m'
|
||||||
|
YELLOW='\033[0;33m'
|
||||||
|
LIGHT_GREEN='\033[0;92m'
|
||||||
|
BOLD='\033[1m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
echo_error() {
|
||||||
|
printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_info() {
|
||||||
|
printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_warning() {
|
||||||
|
printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_note() {
|
||||||
|
printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
||||||
|
command_exists() {
|
||||||
|
command -v "$@" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# ─< Check if the user is root and set sudo variable if necessary >───────────────────────
|
||||||
|
check_root() {
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
if command_exists sudo; then
|
||||||
|
echo_info "User is not root. Using sudo for privileged operations."
|
||||||
|
_sudo="sudo -E"
|
||||||
|
else
|
||||||
|
echo_error "No sudo found and you're not root! Can't install packages."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo_info "Root access confirmed."
|
||||||
|
_sudo=""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if ! command_exists git; then
|
||||||
|
echo_error "Some dependencies are missing!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
clone() {
|
||||||
|
local cloneDir="/opt/shell-color-scripts"
|
||||||
|
if [ ! -d "$cloneDir" ]; then
|
||||||
|
$_sudo git clone --depth=1 https://github.com/charitarthchugh/shell-color-scripts "$cloneDir" &&
|
||||||
|
$_sudo chmod +x "$cloneDir/colorscript.sh"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
link() {
|
||||||
|
if [ -d "$HOME/.local/bin" ]; then
|
||||||
|
$_sudo ln -sfr /opt/shell-color-scripts/colorscript.sh "$HOME/.local/bin/colorscript" || echo_error "Could not link the script"
|
||||||
|
$_sudo ln -sfr /opt/shell-color-scripts/colorscript.sh /usr/bin/colorscript || echo_error "Could not link the script"
|
||||||
|
else
|
||||||
|
$_sudo ln -sfr /opt/shell-color-scripts/colorscript.sh /usr/bin/colorscript || echo_error "Could not link the script"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
checkInstall() {
|
||||||
|
if command_exists colorscript; then
|
||||||
|
echo_note "Installation complete"
|
||||||
|
else
|
||||||
|
echo_warning "Something went wrong?"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_root &&
|
||||||
|
if clone; then
|
||||||
|
link
|
||||||
|
fi
|
||||||
|
|
||||||
|
checkInstall
|
223
debian/neovim.sh
vendored
Normal file
223
debian/neovim.sh
vendored
Normal file
|
@ -0,0 +1,223 @@
|
||||||
|
{
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
# ANSI color codes
|
||||||
|
RED='\033[0;31m'
|
||||||
|
CYAN='\033[0;36m'
|
||||||
|
YELLOW='\033[0;33m'
|
||||||
|
LIGHT_GREEN='\033[0;92m'
|
||||||
|
BOLD='\033[1m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
echo_error() {
|
||||||
|
printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_info() {
|
||||||
|
printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_warning() {
|
||||||
|
printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_note() {
|
||||||
|
printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
||||||
|
command_exists() {
|
||||||
|
command -v "$@" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if the user is root and set sudo variable if necessary
|
||||||
|
check_root() {
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
echo_note "checked $(id -u)"
|
||||||
|
if command_exists sudo; then
|
||||||
|
echo_note "Checking sudo"
|
||||||
|
echo_warning "User is not root. Using sudo for privileged operations."
|
||||||
|
_sudo="sudo"
|
||||||
|
else
|
||||||
|
echo_error "No sudo found and you're not root! Can't install packages."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo_info "Root access confirmed."
|
||||||
|
_sudo=""
|
||||||
|
fi
|
||||||
|
if [ -n "$_sudo" ]; then
|
||||||
|
echo_info "--- check_root done --- echo '$_sudo' |"
|
||||||
|
else
|
||||||
|
echo_warning "sudo variable is empty: $_sudo"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# ─< Dependencies >─────────────────────────────────────────────────────────────────────
|
||||||
|
deps="git cargo meson luarocks pipx curl ripgrep make composer npm gcc g++ unzip zip"
|
||||||
|
|
||||||
|
# ─< Distribution-specific installation functions >─────────────────────────────────────
|
||||||
|
inst_ubuntu() {
|
||||||
|
$_sudo apt-get update
|
||||||
|
for _deps in $deps; do
|
||||||
|
$_sudo apt-get install -y "$_deps"
|
||||||
|
done
|
||||||
|
inst_generic
|
||||||
|
}
|
||||||
|
|
||||||
|
inst_debian() {
|
||||||
|
$_sudo apt-get update
|
||||||
|
for _deps in $deps; do
|
||||||
|
$_sudo apt-get install -y "$_deps"
|
||||||
|
done
|
||||||
|
inst_generic
|
||||||
|
}
|
||||||
|
|
||||||
|
inst_fedora() {
|
||||||
|
$_sudo dnf update
|
||||||
|
for _deps in $deps; do
|
||||||
|
$_sudo dnf install -y "$_deps"
|
||||||
|
done
|
||||||
|
$_sudo dnf install -y neovim
|
||||||
|
}
|
||||||
|
|
||||||
|
inst_arch() {
|
||||||
|
$_sudo pacman -Syu --noconfirm
|
||||||
|
for _deps in $deps; do
|
||||||
|
$_sudo pacman -S --noconfirm "$_deps"
|
||||||
|
done
|
||||||
|
$_sudo pacman -S --noconfirm --needed neovim
|
||||||
|
}
|
||||||
|
|
||||||
|
inst_opensuse() {
|
||||||
|
$_sudo zypper refresh
|
||||||
|
for _deps in $deps; do
|
||||||
|
$_sudo zypper in "$_deps"
|
||||||
|
done
|
||||||
|
$_sudo zypper in neovim
|
||||||
|
}
|
||||||
|
|
||||||
|
inst_alpine() {
|
||||||
|
$_sudo apk update
|
||||||
|
for _deps in $deps; do
|
||||||
|
$_sudo apk add "$_deps"
|
||||||
|
done
|
||||||
|
$_sudo apk add neovim
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_info "Fetching latest stable Neovim version..."
|
||||||
|
latest_version=$(curl -s https://api.github.com/repos/neovim/neovim/releases/latest | grep 'tag_name' | cut -d\" -f4)
|
||||||
|
|
||||||
|
inst_generic() {
|
||||||
|
tempdir="$(mktemp -d)"
|
||||||
|
if [ ! -d "$HOME/.bin" ]; then
|
||||||
|
mkdir -p "$HOME/.bin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo_info "Downloading Neovim version $latest_version..."
|
||||||
|
|
||||||
|
# Determine architecture
|
||||||
|
arch=$(uname -m)
|
||||||
|
if [ "$arch" = "aarch64" ] || [ "$arch" = "armv7l" ]; then
|
||||||
|
nvim_tarball="nvim-linux-arm64.tar.gz"
|
||||||
|
else
|
||||||
|
nvim_tarball="nvim-linux-x86_64.tar.gz"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Download the tarball
|
||||||
|
curl -fsSL -o "$tempdir/nvim.tar.gz" "https://github.com/neovim/neovim/releases/download/${latest_version}/${nvim_tarball}"
|
||||||
|
|
||||||
|
# Change to the temporary directory and extract
|
||||||
|
cd "$tempdir"
|
||||||
|
tar -xzf nvim.tar.gz
|
||||||
|
|
||||||
|
# Remove old installation if it exists
|
||||||
|
rm -rf "$HOME/.bin/nvim-linux-x86_64" "$HOME/.bin/nvim-linux-arm64"
|
||||||
|
|
||||||
|
# Copy to destination
|
||||||
|
cp -r ./nvim-linux-* "$HOME/.bin/"
|
||||||
|
|
||||||
|
# Create symlinks with absolute paths
|
||||||
|
inst_paths="/usr/bin /usr/share/bin $HOME/.local/bin"
|
||||||
|
for in_path in $inst_paths; do
|
||||||
|
if [ -d "$in_path" ]; then
|
||||||
|
echo_info "Installing into $in_path"
|
||||||
|
$_sudo ln -sf "$HOME/.bin/nvim-linux-*/bin/nvim" "$in_path/nvim"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -rf "$tempdir"
|
||||||
|
|
||||||
|
echo_info "Neovim $latest_version installed successfully"
|
||||||
|
}
|
||||||
|
|
||||||
|
checkVersion() {
|
||||||
|
currentVersion="$(nvim --version | head -n1 | awk '{print $2}')"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ─< Distribution detection and installation >────────────────────────────────────────
|
||||||
|
get_packager() {
|
||||||
|
if [ -e /etc/os-release ]; then
|
||||||
|
echo_info "Detecting distribution..."
|
||||||
|
. /etc/os-release
|
||||||
|
|
||||||
|
# Convert $ID and $ID_LIKE to lowercase
|
||||||
|
ID=$(printf "%s" "$ID" | tr '[:upper:]' '[:lower:]')
|
||||||
|
ID_LIKE=$(printf "%s" "$ID_LIKE" | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
|
case "$ID" in
|
||||||
|
ubuntu | pop) inst_ubuntu ;;
|
||||||
|
debian) inst_debian ;;
|
||||||
|
fedora) inst_fedora ;;
|
||||||
|
alpine) inst_alpine ;;
|
||||||
|
arch | manjaro | garuda | endeavour) inst_arch ;;
|
||||||
|
opensuse*) inst_opensuse ;;
|
||||||
|
*)
|
||||||
|
if [ "${ID_LIKE#*debian}" != "$ID_LIKE" ]; then
|
||||||
|
inst_debian
|
||||||
|
elif [ "${ID_LIKE#*ubuntu}" != "$ID_LIKE" ]; then
|
||||||
|
inst_ubuntu
|
||||||
|
elif [ "${ID_LIKE#*arch}" != "$ID_LIKE" ]; then
|
||||||
|
inst_arch
|
||||||
|
elif [ "${ID_LIKE#*fedora}" != "$ID_LIKE" ]; then
|
||||||
|
inst_fedora
|
||||||
|
elif [ "${ID_LIKE#*suse}" != "$ID_LIKE" ]; then
|
||||||
|
inst_opensuse
|
||||||
|
else
|
||||||
|
echo_error "Unsupported distribution: $ID"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
echo_error "Unable to detect distribution. /etc/os-release not found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# ─< Main function >─────────────────────────────────────────────────────────────────
|
||||||
|
main() {
|
||||||
|
if command_exists nvim; then
|
||||||
|
checkVersion
|
||||||
|
if [ "$(printf '%s\n' "$latest_version" "$currentVersion" | sort -V | head -n1)" = "$latest_version" ]; then
|
||||||
|
echo_warning "Neovim is already installed in version: $currentVersion"
|
||||||
|
echo_error "Exiting now!"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo_info "Starting Neovim installation script..."
|
||||||
|
get_packager
|
||||||
|
if command -v nvim >/dev/null 2>&1; then
|
||||||
|
echo_note "Neovim has been successfully installed!"
|
||||||
|
echo_info "Neovim version: $(nvim --version | head -n1)"
|
||||||
|
else
|
||||||
|
echo_error "Neovim installation failed."
|
||||||
|
# exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# ─< Script execution >─────────────────────────────────────────────────────────────
|
||||||
|
check_root && main
|
||||||
|
}
|
8
debian/setupDebian.sh
vendored
Executable file
8
debian/setupDebian.sh
vendored
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
cd $HOME/dotfiles/
|
||||||
|
|
||||||
|
stow dotfiles/
|
||||||
|
stow zsh/
|
||||||
|
|
||||||
|
exec zsh
|
140
debian/zellij.sh
vendored
Normal file
140
debian/zellij.sh
vendored
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
generic() {
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
INSTALL_DIR="${HOME}/.local/bin" # Prefer ~/.local/bin (add to PATH if not already)
|
||||||
|
BINARY_NAME="zellij"
|
||||||
|
REPO="zellij-org/zellij"
|
||||||
|
TMP_DIR=$(mktemp -d)
|
||||||
|
|
||||||
|
# Cleanup on exit
|
||||||
|
trap 'rm -rf "$TMP_DIR"' EXIT
|
||||||
|
|
||||||
|
# Ensure install directory exists
|
||||||
|
mkdir -p "$INSTALL_DIR"
|
||||||
|
|
||||||
|
# Check if zellij is already installed
|
||||||
|
current_version=""
|
||||||
|
if command -v "$BINARY_NAME" >/dev/null 2>&1; then
|
||||||
|
current_version=$($BINARY_NAME --version | awk '{print $2}')
|
||||||
|
echo "ℹ️ Found existing $BINARY_NAME (version: $current_version)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fetch latest release from GitHub
|
||||||
|
echo "🔍 Checking latest release of $REPO..."
|
||||||
|
latest_release=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||||
|
latest_version=${latest_release#v} # Remove 'v' prefix (e.g., v0.42.2 → 0.42.2)
|
||||||
|
|
||||||
|
# Detect system architecture
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
case "$ARCH" in
|
||||||
|
x86_64)
|
||||||
|
ARCH="x86_64"
|
||||||
|
;;
|
||||||
|
aarch64 | arm64)
|
||||||
|
ARCH="aarch64"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "❌ Unsupported architecture: $ARCH" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
download_url="https://github.com/$REPO/releases/download/$latest_release/$BINARY_NAME-$ARCH-unknown-linux-musl.tar.gz"
|
||||||
|
|
||||||
|
# Skip if already up-to-date
|
||||||
|
if [[ "$current_version" == "$latest_version" ]]; then
|
||||||
|
echo "✅ Already on the latest version ($latest_version). No action needed."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Download and install
|
||||||
|
echo "⬇️ Downloading $BINARY_NAME $latest_version for $ARCH..."
|
||||||
|
curl -sL "$download_url" | tar -xz -C "$TMP_DIR"
|
||||||
|
|
||||||
|
echo "🛠️ Installing to $INSTALL_DIR..."
|
||||||
|
mv -f "$TMP_DIR/$BINARY_NAME" "$INSTALL_DIR/"
|
||||||
|
|
||||||
|
# Verify
|
||||||
|
if [[ -f "$INSTALL_DIR/$BINARY_NAME" ]]; then
|
||||||
|
chmod +x "$INSTALL_DIR/$BINARY_NAME"
|
||||||
|
echo "🎉 Successfully installed $BINARY_NAME $latest_version to $INSTALL_DIR/"
|
||||||
|
echo "💡 Ensure '$INSTALL_DIR' is in your PATH:"
|
||||||
|
echo " export PATH=\"$INSTALL_DIR:\$PATH\""
|
||||||
|
else
|
||||||
|
echo "❌ Installation failed!" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
||||||
|
command_exists() {
|
||||||
|
command -v "$@" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# ─< Check if the user is root and set sudo variable if necessary >───────────────────────
|
||||||
|
check_root() {
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
if command_exists sudo; then
|
||||||
|
echo_info "User is not root. Using sudo for privileged operations."
|
||||||
|
_sudo="sudo"
|
||||||
|
else
|
||||||
|
echo_error "No sudo found and you're not root! Can't install packages."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo_info "Root access confirmed."
|
||||||
|
_sudo=""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# ─< Distribution detection and installation >────────────────────────────────────────
|
||||||
|
get_packager() {
|
||||||
|
if [ -e /etc/os-release ]; then
|
||||||
|
echo_info "Detecting distribution..."
|
||||||
|
. /etc/os-release
|
||||||
|
|
||||||
|
# ─< Convert $ID and $ID_LIKE to lowercase >──────────────────────────────────────────────
|
||||||
|
ID=$(printf "%s" "$ID" | tr '[:upper:]' '[:lower:]')
|
||||||
|
ID_LIKE=$(printf "%s" "$ID_LIKE" | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
|
case "$ID" in
|
||||||
|
ubuntu | pop) generic ;;
|
||||||
|
debian) generic ;;
|
||||||
|
fedora) generic ;;
|
||||||
|
alpine) generic ;;
|
||||||
|
arch | manjaro | garuda | endeavour)
|
||||||
|
if command_exists paru; then
|
||||||
|
paru -S --noconfirm zellij
|
||||||
|
elif command_exists yay; then
|
||||||
|
yay -S --noconfirm zellij
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
opensuse*) generic ;;
|
||||||
|
*)
|
||||||
|
if [ "${ID_LIKE#*debian}" != "$ID_LIKE" ]; then
|
||||||
|
generic
|
||||||
|
elif [ "${ID_LIKE#*ubuntu}" != "$ID_LIKE" ]; then
|
||||||
|
generic
|
||||||
|
elif [ "${ID_LIKE#*arch}" != "$ID_LIKE" ]; then
|
||||||
|
$_sudo pacman -S zellij
|
||||||
|
elif [ "${ID_LIKE#*fedora}" != "$ID_LIKE" ]; then
|
||||||
|
generic
|
||||||
|
elif [ "${ID_LIKE#*suse}" != "$ID_LIKE" ]; then
|
||||||
|
generic
|
||||||
|
else
|
||||||
|
echo_error "Unsupported distribution: $ID"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
echo_error "Unable to detect distribution. /etc/os-release not found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if check_root; then
|
||||||
|
get_packager
|
||||||
|
fi
|
Loading…
Add table
Add a link
Reference in a new issue