diff --git a/README.md b/README.md index 19eee8c..98935af 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Tools are installed to ~/.local/bin/dropshell-tool, and the tool name is added t Just use dropshell-tool. You can install with: ``` -curl https://getbin.xyz/dropshell-tool-install.sh | bash +curl https://getbin.xyz/dropshell-tool-install | bash ``` diff --git a/dropshell-build/publish.sh b/dropshell-build/publish.sh index c66f71a..cdb073d 100755 --- a/dropshell-build/publish.sh +++ b/dropshell-build/publish.sh @@ -4,8 +4,14 @@ set -euo pipefail SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +# upload the dropshell-build script "${SCRIPT_DIR}/../sos/sos" upload "getbin.xyz" "dropshell-build" "${SCRIPT_DIR}/src/dropshell-build" +# upload the install requirements script +"${SCRIPT_DIR}/../sos/sos" upload "getbin.xyz" "dropshell-build-install-requirements" "${SCRIPT_DIR}/src/install_dropshell_build_requirements" + + +# tag and push the dropshell-build image docker tag gitea.jde.nz/public/dropshell-build:test gitea.jde.nz/public/dropshell-build:latest docker push gitea.jde.nz/public/dropshell-build:latest diff --git a/dropshell-tool/build.sh b/dropshell-tool/build.sh index f690e17..27d8ddd 100755 --- a/dropshell-tool/build.sh +++ b/dropshell-tool/build.sh @@ -3,7 +3,7 @@ set -euo pipefail SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -DROPSHELL_BUILD_DIR="${SCRIPT_DIR}/../dropshell-build/" +DROPSHELL_BUILD_DIR="${SCRIPT_DIR}/../dropshell-build/src" # make canonical path DROPSHELL_BUILD_DIR=$(realpath "${DROPSHELL_BUILD_DIR}") @@ -17,9 +17,5 @@ if [ ! -f "${DROPSHELL_BUILD_DIR}/install_dropshell_build_requirements" ]; then exit 1 fi -# install host dependencies -"${DROPSHELL_BUILD_DIR}/install_dropshell_build_requirements" - - # run the build script -"${DROPSHELL_BUILD_DIR}/dropshell-build" "$@" "${SCRIPT_DIR}" +"${DROPSHELL_BUILD_DIR}/dropshell-build" -m -r "${SCRIPT_DIR}" diff --git a/dropshell-tool/dropshell-tool-install b/dropshell-tool/dropshell-tool-install new file mode 100755 index 0000000..538e560 --- /dev/null +++ b/dropshell-tool/dropshell-tool-install @@ -0,0 +1,19 @@ +#!/bin/bash + +set -euo pipefail + +#SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +echo "Installing dropshell-tool" + +ARCH=$(uname -m) + +wget "https://getbin.xyz/dropshell-tool:$ARCH" -O bootstrap && chmod a+x bootstrap + +./bootstrap install dropshell tool + +rm ./bootstrap + +VERSION=$(dropshell-tool version) + +echo "Dropshell tool $VERSION installed" diff --git a/dropshell-tool/publish.sh b/dropshell-tool/publish.sh index 4fc38aa..682bd8b 100755 --- a/dropshell-tool/publish.sh +++ b/dropshell-tool/publish.sh @@ -10,38 +10,41 @@ die() { exit 1 } -MYARCH=$(uname -m) +function publish_install() { + "${SCRIPT_DIR}/../sos/sos" upload "getbin.xyz" "dropshell-tool-install" "dropshell-tool-install" +} -"${SCRIPT_DIR}/build.sh" -m -r || die "Failed to build" +function publish_executables() { + OUTPUT_DIR="${SCRIPT_DIR}/output" + ARCH=$(uname -m) -PUBLISH_DIR="${SCRIPT_DIR}/tool" -OUTPUT_DIR="${SCRIPT_DIR}/output" + # Find all dropshell-tool.ARCH files in output/ + TOOLS=() + for tool in "${SCRIPT_DIR}/output/"/*dropshell-tool.*; do + [ -f "$tool" ] || continue + tool_name=$(basename "$tool") + TOOLS+=("$tool_name") + done -# Find all dropshell-tool.ARCH files in output/ -TOOLS=() -for tool in "${SCRIPT_DIR}/output/"/*dropshell-tool.*; do - [ -f "$tool" ] || continue - tool_name=$(basename "$tool") - TOOLS+=("$tool_name") -done + if [ ${#TOOLS[@]} -eq 0 ]; then + echo "No tools found in ${SCRIPT_DIR}/output/. Exiting." + exit 1 + fi -if [ ${#TOOLS[@]} -eq 0 ]; then - echo "No tools found in ${SCRIPT_DIR}/output/. Exiting." - exit 1 -fi + for TOOL in "${TOOLS[@]}"; do + echo "Publishing $TOOL" -for TOOL in "${TOOLS[@]}"; do - echo "Publishing $TOOL" + # extract the architecture from the tool name + ARCH="${TOOL//dropshell-tool./}" - # extract the architecture from the tool name - ARCH="${TOOL//dropshell-tool./}" + # upload the tool + "${SCRIPT_DIR}/../sos/sos" upload "getbin.xyz" "dropshell-tool:${ARCH}" "$OUTPUT_DIR/$TOOL" + done - # copy the tool to the output/ directory - cp "$OUTPUT_DIR/$TOOL" "$PUBLISH_DIR/dropshell-tool" || die "Failed to copy $TOOL to $PUBLISH_DIR/dropshell-tool" +} - "$OUTPUT_DIR/dropshell-tool.${MYARCH}" publish "dropshell-tool:${ARCH}" "$PUBLISH_DIR" || die "Failed to publish $TOOL" +publish_install +publish_executables - # remove the tool from the output/ directory - rm "$PUBLISH_DIR/dropshell-tool" || die "Failed to remove $PUBLISH_DIR/dropshell-tool" -done +echo "Done" \ No newline at end of file diff --git a/dropshell-tool/test.sh b/dropshell-tool/test.sh new file mode 100755 index 0000000..fb15b82 --- /dev/null +++ b/dropshell-tool/test.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -euo pipefail + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + + +MYARCH=$(uname -m) + +VERSION=$("${SCRIPT_DIR}/output/dropshell-tool.${MYARCH}" version) + +echo "Version: $VERSION" + + diff --git a/dropshell-tool/tool/dropshell-tool-config.json b/dropshell-tool/tool/dropshell-tool-config.json deleted file mode 100644 index 2a229f7..0000000 --- a/dropshell-tool/tool/dropshell-tool-config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "aliases": [], - "setup_script": "setup_script.sh" -} \ No newline at end of file diff --git a/dropshell-tool/tool/setup_script.sh b/dropshell-tool/tool/setup_script.sh deleted file mode 100755 index 5838800..0000000 --- a/dropshell-tool/tool/setup_script.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -echo 'Setup complete.' diff --git a/publish_all.sh b/publish_all.sh index 1a5d436..f32c657 100755 --- a/publish_all.sh +++ b/publish_all.sh @@ -5,8 +5,6 @@ set -euo pipefail SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -# run sos to upload dropshell-tool-install.sh -"${SCRIPT_DIR}/sos/sos" upload "getbin.xyz" "dropshell-tool-install.sh" "${SCRIPT_DIR}/dropshell-tool-install.sh" # build and publish all dropshell tools diff --git a/sos/build.sh b/sos/build.sh new file mode 100755 index 0000000..dee8872 --- /dev/null +++ b/sos/build.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -euo pipefail + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +if [ ! -f "${SCRIPT_DIR}/sos" ]; then + echo "Error: sos not found in ${SCRIPT_DIR}" + exit 1 +fi diff --git a/sos/publish.sh b/sos/publish.sh new file mode 100755 index 0000000..4c8aa00 --- /dev/null +++ b/sos/publish.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -euo pipefail + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +# run sos to upload sos +"${SCRIPT_DIR}/sos" upload "getbin.xyz" "sos:latest" "${SCRIPT_DIR}/sos" diff --git a/sos/sos b/sos/sos index fba13d6..db7547a 100755 --- a/sos/sos +++ b/sos/sos @@ -83,7 +83,7 @@ METADATA_JSON=$(cat < /dev/null && pwd )" + +"${SCRIPT_DIR}/sos" upload "getbin.xyz" "sos:test" "${SCRIPT_DIR}/sos"