66 lines
1.4 KiB
Bash
Executable File
66 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
|
TEMP_DIR=$(mktemp -d)
|
|
|
|
|
|
die() {
|
|
echo -e "Error: $1" >&2
|
|
exit 1
|
|
}
|
|
|
|
function publish_tool() {
|
|
local TOOLPATH="$1"
|
|
local ARCH="$2"
|
|
local TOOL;
|
|
TOOL=$(basename "$TOOLPATH")
|
|
|
|
echo "Publishing $TOOL to getbin.xyz"
|
|
|
|
"${TEMP_DIR}/sos" upload "getbin.xyz" "$TOOL" "$TOOLPATH"
|
|
}
|
|
|
|
function publish_executables() {
|
|
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
|
|
|
|
if [ ${#TOOLS[@]} -eq 0 ]; then
|
|
echo "No tools found in ${SCRIPT_DIR}/output/. Exiting."
|
|
exit 1
|
|
fi
|
|
|
|
for TOOL in "${TOOLS[@]}"; do
|
|
publish_tool "$TOOL" "${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
|
|
|
|
}
|
|
|
|
function getbin() {
|
|
local BIN_NAME="$1"
|
|
|
|
curl -L -o "${TEMP_DIR}/${BIN_NAME}" "https://getbin.xyz/${BIN_NAME}"
|
|
chmod +x "${TEMP_DIR}/${BIN_NAME}"
|
|
}
|
|
|
|
|
|
|
|
getbin "sos"
|
|
publish_executables
|
|
|
|
rm -rf "${TEMP_DIR}"
|
|
echo "Done" |