added php installs.

This commit is contained in:
2026-05-21 11:35:44 +02:00
parent 17144b3a74
commit 456c2593a4
+103 -101
View File
@@ -13,143 +13,145 @@ DO_INSTALL=false
CONFIRM_MODE=true # only true when no args are passed CONFIRM_MODE=true # only true when no args are passed
usage() { usage() {
echo "Usage: $0 [-l] [-i]" echo "Usage: $0 [-l] [-i]"
echo " -l Only create symlinks (no confirmation)" echo " -l Only create symlinks (no confirmation)"
echo " -i Only install system packages (no confirmation)" echo " -i Only install system packages (no confirmation)"
echo " (no args = do both, with confirmation)" echo " (no args = do both, with confirmation)"
exit 1 exit 1
} }
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
DO_LINKS=true DO_LINKS=true
DO_INSTALL=true DO_INSTALL=true
CONFIRM_MODE=true CONFIRM_MODE=true
else else
CONFIRM_MODE=false CONFIRM_MODE=false
while getopts ":lih" opt; do while getopts ":lih" opt; do
case $opt in case $opt in
l) DO_LINKS=true ;; l) DO_LINKS=true ;;
i) DO_INSTALL=true ;; i) DO_INSTALL=true ;;
h) usage ;; h) usage ;;
*) usage ;; *) usage ;;
esac esac
done done
fi fi
# --------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------
## Helper function for linking ## Helper function for linking
# --------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------
link_file() { link_file() {
local src="$1" local src="$1"
local dest="$2" local dest="$2"
if [ -L "$dest" ]; then if [ -L "$dest" ]; then
if [ "$(readlink "$dest")" == "$src" ]; then if [ "$(readlink "$dest")" == "$src" ]; then
echo "✅ Symlink already correct: $dest$src" echo "✅ Symlink already correct: $dest$src"
((SKIPPED++)) ((SKIPPED++))
else else
echo "⚠️ $dest is a symlink but points to the wrong target." echo "⚠️ $dest is a symlink but points to the wrong target."
echo " Replacing with correct symlink..." echo " Replacing with correct symlink..."
rm "$dest" rm "$dest"
ln -s "$src" "$dest" ln -s "$src" "$dest"
echo "🔁 Fixed: $dest$src" echo "🔁 Fixed: $dest$src"
((CREATED++)) ((CREATED++))
fi fi
elif [ -e "$dest" ]; then elif [ -e "$dest" ]; then
echo "⚠️ $dest exists but is not a symlink. Skipping." echo "⚠️ $dest exists but is not a symlink. Skipping."
((SKIPPED++)) ((SKIPPED++))
else else
mkdir -p "$(dirname "$dest")" mkdir -p "$(dirname "$dest")"
ln -s "$src" "$dest" ln -s "$src" "$dest"
echo "✅ Linked: $dest$src" echo "✅ Linked: $dest$src"
((CREATED++)) ((CREATED++))
fi fi
} }
# --------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------
## LINK SYMLINKS ## LINK SYMLINKS
# --------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------
if [ "$DO_LINKS" = true ]; then if [ "$DO_LINKS" = true ]; then
if [ "$CONFIRM_MODE" = true ]; then if [ "$CONFIRM_MODE" = true ]; then
read -p "❓ Do you want to create symlinks for your dotfiles? [y/N] " confirm read -p "❓ Do you want to create symlinks for your dotfiles? [y/N] " confirm
case "$confirm" in case "$confirm" in
[Yy]*) ;; # continue below [Yy]*) ;; # continue below
*) DO_LINKS=false ;; *) DO_LINKS=false ;;
esac esac
fi fi
fi fi
if [ "$DO_LINKS" = true ]; then if [ "$DO_LINKS" = true ]; then
echo "🔗 Checking and creating symlinks..." echo "🔗 Checking and creating symlinks..."
CREATED=0 CREATED=0
SKIPPED=0 SKIPPED=0
link_file "$DOTFILES_DIR/config/tmux" "$HOME/.config/tmux" link_file "$DOTFILES_DIR/config/tmux" "$HOME/.config/tmux"
link_file "$DOTFILES_DIR/config/kanata" "$HOME/.config/kanata" link_file "$DOTFILES_DIR/config/kanata" "$HOME/.config/kanata"
link_file "$DOTFILES_DIR/config/fish" "$HOME/.config/fish" link_file "$DOTFILES_DIR/config/fish" "$HOME/.config/fish"
link_file "$DOTFILES_DIR/config/alacritty" "$HOME/.config/alacritty" link_file "$DOTFILES_DIR/config/alacritty" "$HOME/.config/alacritty"
link_file "$DOTFILES_DIR/config/nvim" "$HOME/.config/nvim" link_file "$DOTFILES_DIR/config/nvim" "$HOME/.config/nvim"
link_file "$DOTFILES_DIR/config/gitu" "$HOME/.config/gitu" link_file "$DOTFILES_DIR/config/gitu" "$HOME/.config/gitu"
link_file "$DOTFILES_DIR/config/lf" "$HOME/.config/lf" link_file "$DOTFILES_DIR/config/lf" "$HOME/.config/lf"
echo "" echo ""
echo "🧾 Summary: $CREATED symlink(s) created or fixed, $SKIPPED skipped." echo "🧾 Summary: $CREATED symlink(s) created or fixed, $SKIPPED skipped."
echo "" echo ""
echo "✅ Symlink setup complete." echo "✅ Symlink setup complete."
echo "" echo ""
fi fi
# --------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------
## INSTALL SYSTEM PACKAGES ## INSTALL SYSTEM PACKAGES
# --------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------
if [ "$DO_INSTALL" = true ]; then if [ "$DO_INSTALL" = true ]; then
if [ "$CONFIRM_MODE" = true ]; then if [ "$CONFIRM_MODE" = true ]; then
read -p "❓ Do you want to install system packages? [y/N] " confirm read -p "❓ Do you want to install system packages? [y/N] " confirm
case "$confirm" in case "$confirm" in
[Yy]*) ;; # continue below [Yy]*) ;; # continue below
*) DO_INSTALL=false ;; *) DO_INSTALL=false ;;
esac esac
fi fi
fi fi
if [ "$DO_INSTALL" = true ]; then if [ "$DO_INSTALL" = true ]; then
REQUIRED_PACKAGES=( REQUIRED_PACKAGES=(
# system essentials # system essentials
wget curl git unzip lf jq alacritty fzf wget curl git unzip lf jq alacritty fzf
fd-find direnv ripgrep tree bat syncthing fd-find direnv ripgrep tree bat syncthing
build-essential make bear valgrind fish build-essential make bear valgrind fish
tmux ca-certificates gnupg libfuse2 tmux ca-certificates gnupg libfuse2
fonts-symbola fonts-noto fonts-noto-color-emoji fonts-symbola fonts-noto fonts-noto-color-emoji
) # php
php-cli php-mysql php-curl php-mbstring php-zip
)
MISSING_PACKAGES=() MISSING_PACKAGES=()
echo "🔍 Checking for missing packages..." echo "🔍 Checking for missing packages..."
echo "" echo ""
# Check which packages are missing using dpkg # Check which packages are missing using dpkg
for pkg in "${REQUIRED_PACKAGES[@]}"; do for pkg in "${REQUIRED_PACKAGES[@]}"; do
# dpkg-query checks for the installed status. # dpkg-query checks for the installed status.
# We check for a non-zero exit status which indicates the package is NOT installed. # We check for a non-zero exit status which indicates the package is NOT installed.
if ! dpkg-query -W -f='${Status}' "$pkg" 2>/dev/null | grep -q "install ok installed"; then if ! dpkg-query -W -f='${Status}' "$pkg" 2>/dev/null | grep -q "install ok installed"; then
MISSING_PACKAGES+=("$pkg") MISSING_PACKAGES+=("$pkg")
fi fi
done done
if [ ${#MISSING_PACKAGES[@]} -eq 0 ]; then if [ ${#MISSING_PACKAGES[@]} -eq 0 ]; then
echo "✅ All required packages are already installed." echo "✅ All required packages are already installed."
else else
echo "📦 Updating package lists..." echo "📦 Updating package lists..."
# Update package lists before installing # Update package lists before installing
sudo apt update sudo apt update
echo "📦 Installing missing packages: ${MISSING_PACKAGES[*]}" echo "📦 Installing missing packages: ${MISSING_PACKAGES[*]}"
# Use sudo apt install for installing on Debian # Use sudo apt install for installing on Debian
sudo apt install "${MISSING_PACKAGES[@]}" sudo apt install "${MISSING_PACKAGES[@]}"
fi fi
echo "" echo ""
echo "✅ Package setup complete." echo "✅ Package setup complete."
echo "" echo ""
fi fi