Skip to content

Commit

Permalink
install
Browse files Browse the repository at this point in the history
  • Loading branch information
nokonoko1203 committed Nov 27, 2024
1 parent f28579f commit ac9a814
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ A tool for converting point cloud data (las/laz and csv) into "3D Tiles v1.1".

## install

Enter the following command.

```sh
curl -sSf https://raw.githubusercontent.com/MIERUNE/point-tiler/main/scripts/install.sh | bash
export PATH="/usr/local/bin/point_tiler:$PATH"
```

### for developer

Rust must be installed. You can easily install it from the following page.

[Getting started](https://www.rust-lang.org/learn/get-started)
Expand Down
82 changes: 82 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/env bash
set -euo pipefail

__wrap__() {

REPO=MIERUNE/point-tiler

VERSION=${POINT_TILER_VERSION:-latest}

if ! command -v curl > /dev/null 2>&1; then
echo "Error: 'curl' is required but not installed. Please install it and try again."
exit 1
fi

if [[ $VERSION == "latest" ]]; then
VERSION=$(curl -sL "https://api.github.com/repos/${REPO}/releases/latest" | sed -n 's/.*"tag_name": "\([^"]*\)".*/\1/p')
if [[ -z $VERSION ]]; then
echo "Error: Unable to detect the latest version. Please check your internet connection or the repository."
exit 1
fi
fi

PLATFORM=$(uname -s)
ARCH=$(uname -m)

if [[ $PLATFORM == "Darwin" ]]; then
PLATFORM="apple-darwin"
elif [[ $PLATFORM == "Linux" ]]; then
PLATFORM="unknown-linux-gnu"
else
echo "Error: Unsupported platform $PLATFORM"
exit 1
fi

if [[ $ARCH == armv8* ]] || [[ $ARCH == arm64* ]] || [[ $ARCH == aarch64* ]]; then
ARCH="aarch64"
elif [[ $ARCH == i686* ]] || [[ $ARCH == x86_64 ]]; then
ARCH="x86_64"
else
echo "Error: Unsupported architecture $ARCH"
exit 1
fi

BINARY="point_tiler-${VERSION}-${ARCH}-${PLATFORM}"

DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${VERSION}/${BINARY}"

echo "This script will automatically download and install point_tiler (${VERSION}) for you."

if [ "x$(id -u)" == "x0" ]; then
echo "Warning: this script is running as root. This is dangerous and unnecessary!"
fi

TEMP_DIR=$(mktemp -d)
TEMP_FILE="$TEMP_DIR/point_tiler"
cleanup() {
rm -rf "$TEMP_DIR"
}

trap cleanup EXIT

HTTP_CODE=$(curl -SL --progress-bar "$DOWNLOAD_URL" --output "$TEMP_FILE" --write-out "%{http_code}")
if [[ ${HTTP_CODE} -lt 200 || ${HTTP_CODE} -gt 299 ]]; then
echo "Error: platform ${PLATFORM} (${ARCH}) or version ${VERSION} is unsupported."
exit 1
fi

chmod +x "$TEMP_FILE"

INSTALL_DIR="/usr/local/bin"
if [[ ! -w $INSTALL_DIR ]]; then
echo "Error: The install directory $INSTALL_DIR is not writable."
echo "Please run the script with appropriate permissions or install to a directory you have write access to."
exit 1
fi
mv "$TEMP_FILE" "$INSTALL_DIR/point_tiler"


echo "point_tiler has been installed successfully to $INSTALL_DIR/point_tiler"
}

__wrap__

0 comments on commit ac9a814

Please sign in to comment.