OpenSCAD/install.sh

66 lines
1.7 KiB
Bash

#!/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-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/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 (force cloning)
for ((i = 0; i < ${#library_names[@]}; i++)); do
lib="${library_names[$i]}"
url="${library_urls[$i]}"
if [ -d "$lib" ]; then
echo "Removing existing directory for $lib..."
rm -rf "$lib"
fi
echo "Cloning $lib from $url..."
git clone "$url" "$lib"
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."