From 3b36456a5d33fdb48b6fbed750464dfdcf301c26 Mon Sep 17 00:00:00 2001 From: Logan Gorence Date: Wed, 22 Dec 2021 23:53:06 +0000 Subject: [PATCH] Add install script. --- install.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 install.sh diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..c00d41c --- /dev/null +++ b/install.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +set -e + +echo "This script installs Foundation, it is developed against Paper and may depend on" +echo "Paper-specific features." +echo +echo "Installing..." + +# Create the plugins directory if it doesn't exist. +if [ ! -d plugins ]; then + echo "Creating plugins directory." + mkdir plugins/ +fi + +# Base GitLab update manifest. +base_url="https://git.gorence.io/lgorence/foundation/-/jobs/artifacts/main/raw/" +query_params="job=build" + +# Download the update manifest. +manifest=$(curl -Ls "$base_url/build/manifests/update.json?$query_params") + +# Get plugins list from the manifest. +plugins=$(echo "$manifest" | jq -r 'keys | .[]') + +# Download each plugin from the manifest, can also update plugins. +for plugin in $plugins +do + # Determine download path, extract version and artifact path URL. + dl_path="plugins/$plugin.jar" + version=$(echo "$manifest" | jq -r " .[\"$plugin\"].version") + artifact_path=$(echo "$manifest" | jq -r " .[\"$plugin\"].artifacts[0]") + + echo "Installing $plugin v$version to $dl_path" + + # Download the plugin and store it at the mentioned path. + curl -Ls "$base_url/$artifact_path?$query_params" --output "$dl_path" +done