Add tool config system to setup.sh
- Add .dotfiles-tools config file with tool definitions - setup.sh now parses config and installs by priority - Add --with-optional/-w flag to auto-install optional tools - Includes: bash, kitty, vim, git, curl (required), rust, opencode, dua (optional)
This commit is contained in:
15
.dotfiles-tools
Normal file
15
.dotfiles-tools
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Tool configurations for dotfiles setup
|
||||||
|
# Format: name|command_to_check_installed|install_command|priority
|
||||||
|
# priority: required (install always), optional (ask user), extra (skip by default)
|
||||||
|
|
||||||
|
# Required - core tools
|
||||||
|
bash|/usr/bin/bash|sudo apt install -y bash|required
|
||||||
|
kitty|/usr/bin/kitty|sudo apt install -y kitty|required
|
||||||
|
vim|/usr/bin/vim|sudo apt install -y vim-gtk3|required
|
||||||
|
git|/usr/bin/git|sudo apt install -y git|required
|
||||||
|
curl|/usr/bin/curl|sudo apt install -y curl|required
|
||||||
|
|
||||||
|
# Optional - additional tools
|
||||||
|
rust|/usr/bin/cargo|curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y|optional
|
||||||
|
opencode|/usr/bin/opencode|curl -fsSL https://opencode.ai/install | sh|optional
|
||||||
|
dua|/usr/bin/dua|curl -LSfs https://raw.githubusercontent.com/Byron/dua-cli/master/ci/install.sh | sh -s -- --git Byron/dua-cli --target x86_64-unknown-linux-musl --crate dua --tag v2.29.0|optional
|
||||||
76
setup.sh
76
setup.sh
@@ -1,7 +1,10 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
TOOLS_FILE="$HOME/.dotfiles-tools"
|
||||||
|
|
||||||
# CLI: parse flags
|
# CLI: parse flags
|
||||||
PROMPT_DELETE=1
|
PROMPT_DELETE=1
|
||||||
|
INSTALL_OPTIONAL=0
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--no-prompt|-n)
|
--no-prompt|-n)
|
||||||
@@ -12,38 +15,70 @@ while [[ $# -gt 0 ]]; do
|
|||||||
PROMPT_DELETE=1
|
PROMPT_DELETE=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--with-optional|-w)
|
||||||
|
INSTALL_OPTIONAL=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*) break
|
*) break
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
echo ">>> Bootstrapping new Debian-like machine..."
|
echo ">>> Bootstrapping new Debian-like machine..."
|
||||||
|
|
||||||
# 1. Update package list and install essentials
|
# Parse tools from config file
|
||||||
echo ">>> Installing bash, kitty, and vim..."
|
parse_tools() {
|
||||||
|
local priority="$1"
|
||||||
|
while IFS='|' read -r name check_cmd install_cmd prio; do
|
||||||
|
[[ "$name" =~ ^#.*$ ]] && continue
|
||||||
|
[[ -z "$name" ]] && continue
|
||||||
|
[[ "$prio" == "$priority" ]] && echo "$name|$check_cmd|$install_cmd"
|
||||||
|
done < "$TOOLS_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install required tools
|
||||||
|
echo ">>> Installing required tools..."
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install -y bash kitty vim-gtk3 git curl
|
while IFS='|' read -r name check_cmd install_cmd prio; do
|
||||||
|
[[ "$prio" != "required" ]] && continue
|
||||||
|
if ! command -v "$name" &> /dev/null && [[ "$prio" == "required" ]]; then
|
||||||
|
echo ">>> Installing $name..."
|
||||||
|
eval "$install_cmd"
|
||||||
|
fi
|
||||||
|
done < "$TOOLS_FILE"
|
||||||
|
|
||||||
# Install Rust
|
# Ask about optional tools
|
||||||
echo ">>> Installing Rust..."
|
if [[ "$INSTALL_OPTIONAL" == "1" ]] || [[ "$PROMPT_DELETE" == "1" ]]; then
|
||||||
if ! command -v rustc &> /dev/null; then
|
echo ""
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
echo ">>> Optional tools available:"
|
||||||
|
while IFS='|' read -r name check_cmd install_cmd prio; do
|
||||||
|
[[ "$prio" != "optional" ]] && continue
|
||||||
|
if ! command -v "$name" &> /dev/null; then
|
||||||
|
echo " - $name"
|
||||||
|
fi
|
||||||
|
done < "$TOOLS_FILE"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
if [[ "$PROMPT_DELETE" == "1" ]] && [[ -t 1 ]]; then
|
||||||
|
read -r -p "Install optional tools? (y/N): " resp
|
||||||
|
case "$resp" in
|
||||||
|
[Yy]* ) INSTALL_OPTIONAL=1 ;;
|
||||||
|
* ) INSTALL_OPTIONAL=0 ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install opencode
|
if [[ "$INSTALL_OPTIONAL" == "1" ]]; then
|
||||||
echo ">>> Installing OpenCode..."
|
echo ">>> Installing optional tools..."
|
||||||
if ! command -v opencode &> /dev/null; then
|
while IFS='|' read -r name check_cmd install_cmd prio; do
|
||||||
curl -fsSL https://opencode.ai/install | sh
|
[[ "$prio" != "optional" ]] && continue
|
||||||
|
if ! command -v "$name" &> /dev/null; then
|
||||||
|
echo ">>> Installing $name..."
|
||||||
|
eval "$install_cmd"
|
||||||
|
fi
|
||||||
|
done < "$TOOLS_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install dua-cli (disk usage)
|
# Clone dotfiles
|
||||||
echo ">>> Installing dua-cli..."
|
|
||||||
if ! command -v dua &> /dev/null; then
|
|
||||||
curl -fsSL https://github.com/Byron/dua-cli/releases/download/v*/dua-*-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C /tmp
|
|
||||||
sudo mv /tmp/dua-*/dua /usr/local/bin/
|
|
||||||
rm -rf /tmp/dua-*
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 2. Clone your dotfiles (bare repo style)
|
|
||||||
if [ ! -d "$HOME/.dotfiles" ]; then
|
if [ ! -d "$HOME/.dotfiles" ]; then
|
||||||
echo ">>> Cloning dotfiles repo..."
|
echo ">>> Cloning dotfiles repo..."
|
||||||
git clone --bare https://gitea.sjhl.nz/james/dotfiles $HOME/.dotfiles
|
git clone --bare https://gitea.sjhl.nz/james/dotfiles $HOME/.dotfiles
|
||||||
@@ -51,7 +86,6 @@ else
|
|||||||
echo ">>> Dotfiles repo already exists."
|
echo ">>> Dotfiles repo already exists."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 3. Checkout dotfiles
|
|
||||||
dotfiles() {
|
dotfiles() {
|
||||||
/usr/bin/git --git-dir="$HOME/.dotfiles/" --work-tree="$HOME" "$@"
|
/usr/bin/git --git-dir="$HOME/.dotfiles/" --work-tree="$HOME" "$@"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user