#!/bin/bash if ! command -v brew >/dev/null 2>&1; then echo "Homebrew is not installed. Please install Homebrew first: https://brew.sh/" exit 1 fi if ! brew list openscad >/dev/null 2>&1; then brew install openscad fi if ! [ -d ~/Documents/OpenSCAD/libraries/ ]; then mkdir -p ~/Documents/OpenSCAD/libraries/ fi cd ~/Documents/OpenSCAD/libraries/ # Separate arrays for library names and their corresponding URLs library_names=( "BOSL2" "BOSL" "MCAD" "nutsnbolts" "openscad-fillets" "openscad-model-library" "OpenSCAD-Arduino-Mounting-Library" "BezierScad" "Chamfers-for-OpenSCAD" ) library_urls=( "https://github.com/BelfrySCAD/BOSL2.git" "https://github.com/revarbat/BOSL.git" "https://github.com/openscad/MCAD.git" "https://github.com/JohK/nutsnbolts.git" "https://github.com/jfhbrook/openscad-fillets.git" "https://github.com/cznewt/openscad-model-library.git" "https://github.com/kellyegan/OpenSCAD-Arduino-Mounting-Library.git" "https://github.com/chadkirby/BezierScad.git" "https://github.com/SebiTimeWaster/Chamfers-for-OpenSCAD.git" ) # Clone or update each library for ((i = 0; i < ${#library_names[@]}; i++)); do lib="${library_names[$i]}" url="${library_urls[$i]}" if ! [ -d "$lib" ]; then git clone "$url" "$lib" else cd "$lib" git pull cd .. fi done # Verify OpenSCAD installation if ! command -v openscad >/dev/null 2>&1; then echo "OpenSCAD installation failed. Please verify your Homebrew setup." exit 1 fi # Verify library setup for lib in "${library_names[@]}"; do if [ ! -d "$lib" ]; then echo "Library $lib setup failed. Verify git and directory permissions." exit 1 fi done echo "OpenSCAD and libraries successfully installed and configured."