Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ The BOSL2 library is an enormous library that provides many different kinds of c
You can find the full BOSL2 library documentation at: https://github.com/BelfrySCAD/BOSL2/wiki


## Installation
## Automated Install/Update with Git

`curl -sSL https://raw.githubusercontent.com/BelfrySCAD/BOSL2/refs/heads/master/get_bosl2.sh | bash`


## Manual Installation

1. Download the .zip or .tar.gz release file for this library. Currently you should be able to find this at https://github.com/BelfrySCAD/BOSL2/archive/refs/heads/master.zip
2. Unpack it. Make sure that you unpack the whole file structure. Some zipfile unpackers call this option "Use folder names". It should create either a `BOSL-v2.0` or `BOSL2-master` directory with the library files within it. You should see "examples", "scripts", "tests", and other subdirectories.
Expand Down
62 changes: 62 additions & 0 deletions get_bosl2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
set -o errexit
set -o nounset

repo_url="https://github.com/BelfrySCAD/BOSL2.git"
lib_target_dirname="BOSL2"

# determine lib dir
if command -v openscad &> /dev/null 2>&1; then
libdir="$(openscad --info 2>/dev/null | grep "OpenSCAD library path:" -A1 | tail -n1 | xargs)"
if [ -z "$libdir" ]; then
echo "ABORT: Could not determine OpenSCAD library path from 'openscad --info'"
exit 1
fi
echo "OpenSCAD library path determined from 'openscad --info': $libdir"
if [ ! -d "$libdir" ]; then
echo "ABORT: Library folder does not exist."
exit 1
fi
if [ ! -x "$libdir" ] || [ ! -w "$libdir" ]; then
echo "ABORT: Library folder is not accessible (write+execute)."
exit 1
fi

else
echo "Could not find 'openscad' command. Guessing library path based on OS."

uname_out="$(uname -s)"
case "${uname_out}" in
Linux*) machine="Linux";;
Darwin*) machine="Mac";;
*) machine="UNKNOWN:${uname_out}"
esac

if [ "$machine" == "Mac" ]; then
libdir="$HOME/Documents/OpenSCAD/libraries"
elif [ "$machine" == "Linux" ]; then
libdir="$HOME/.local/share/OpenSCAD/libraries"
else
echo "WARNING: running on an unknown system: ${machine}."
libdir="$HOME/.local/share/OpenSCAD/libraries"
fi

if [ ! -d "$libdir" ]; then
echo "ABORT: Assumed OpenSCAD library folder '$libdir' does not exist"
exit 1
fi
fi

if ! command -v git &> /dev/null 2>&1; then
echo "ABORT: Git is missing. Please install git."
exit 1
fi

# clone or update
if [ -d "$libdir/$lib_target_dirname" ]; then
echo "Updating BOSL2 library in $libdir/$lib_target_dirname"
git -C "$libdir/$lib_target_dirname" pull
else
echo "New installation into $libdir/$lib_target_dirname"
git clone "$repo_url" "$libdir/$lib_target_dirname"
fi