major refactor

This commit is contained in:
2026-06-19 23:42:18 +05:30
parent a786af12c9
commit e9fbd08423
12 changed files with 621 additions and 356 deletions

30
b.sh
View File

@@ -1,35 +1,33 @@
# >>> bootstrap-cli b function >>>
# Shortcut for downloading and running bootstrap/install scripts
b() {
if [ -z "$1" ]; then
if [ -z "${1:-}" ]; then
echo "Usage: b <script1,script2,...> [args...]" >&2
return 1
fi
local routes_dir="$HOME/.config/bootstrap"
local b_file="$routes_dir/b.sh"
local routes_file="$routes_dir/routes.sh"
local last_update_file="$routes_dir/.last_b_update"
# 1. Check for b.sh updates (once every 24 hours)
local current_time
current_time=$(date +%s 2>/dev/null || date +%s)
local last_update=0
[ -f "$last_update_file" ] && last_update=$(cat "$last_update_file" 2>/dev/null || echo 0)
if [ $((current_time - last_update)) -gt 86400 ]; then
local b_url="https://git.adityagupta.dev/sortedcord/bootstrap/raw/branch/master/b.sh"
if curl -fsSL "$b_url" -o "$b_file" 2>/dev/null; then
echo "$current_time" > "$last_update_file"
. "$b_file" # Load the updated function in current shell context
# Update everything once every 24 hours, or if routes.sh is missing
if [ $((current_time - last_update)) -gt 86400 ] || [ ! -f "$routes_file" ]; then
local bootstrap_url="https://git.adityagupta.dev/sortedcord/bootstrap/raw/branch/master/bootstrap.sh"
local tmp_bootstrap
tmp_bootstrap="$(mktemp)"
# Download and run the bootstrap installer to update all CLI files
if curl -fsSL "$bootstrap_url" -o "$tmp_bootstrap" 2>/dev/null || wget -qO "$tmp_bootstrap" "$bootstrap_url" 2>/dev/null; then
if bash "$tmp_bootstrap"; then
echo "$current_time" > "$last_update_file"
fi
fi
fi
# 2. Update routes.sh on every run
local routes_url="https://git.adityagupta.dev/sortedcord/bootstrap/raw/branch/master/routes.sh"
mkdir -p "$routes_dir"
if curl -fsSL "$routes_url" -o "$routes_file" 2>/dev/null || wget -qO "$routes_file" "$routes_url" 2>/dev/null; then
:
rm -f "$tmp_bootstrap"
fi
if [ ! -f "$routes_file" ]; then
@@ -37,7 +35,7 @@ b() {
return 1
fi
# 3. Execute the routes file
# Execute the routes file
bash "$routes_file" "$@"
}
# <<< bootstrap-cli b function <<<