This commit is contained in:
parent
b9ca132071
commit
32552489f3
@ -4,29 +4,16 @@ set -euo pipefail
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
SOS="${TEMP_DIR}/sos"
|
||||
|
||||
curl -L -o "${SOS}" https://getbin.xyz/sos
|
||||
chmod +x "${SOS}"
|
||||
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 "dropshell-build"
|
||||
|
||||
"${TEMP_DIR}/dropshell-build" "${SCRIPT_DIR}"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# make canonical path
|
||||
DROPSHELL_BUILD_DIR=$(realpath "${DROPSHELL_BUILD_DIR}")
|
||||
|
||||
# make sure the build script exists
|
||||
if [ ! -f "${DROPSHELL_BUILD_DIR}/dropshell-build" ]; then
|
||||
echo "Error: dropshell-build not found"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "${DROPSHELL_BUILD_DIR}/install_dropshell_build_requirements" ]; then
|
||||
echo "Error: install_dropshell_build_requirements not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# run the build script
|
||||
"${DROPSHELL_BUILD_DIR}/dropshell-build" -m -r "${SCRIPT_DIR}"
|
||||
rm -rf "${TEMP_DIR}"
|
||||
|
@ -3,6 +3,7 @@
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
|
||||
|
||||
die() {
|
||||
@ -10,14 +11,19 @@ die() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
function publish_install() {
|
||||
function publish_tool() {
|
||||
local TOOLPATH="$1"
|
||||
local ARCH="$2"
|
||||
local TOOL;
|
||||
TOOL=$(basename "$TOOLPATH")
|
||||
|
||||
"${SCRIPT_DIR}/../sos/sos" upload "getbin.xyz" "dropshell-tool-install" "dropshell-tool-install"
|
||||
echo "Publishing $TOOL to getbin.xyz"
|
||||
|
||||
"${TEMP_DIR}/sos" upload "getbin.xyz" "$TOOL" "$TOOLPATH"
|
||||
}
|
||||
|
||||
function publish_executables() {
|
||||
OUTPUT_DIR="${SCRIPT_DIR}/output"
|
||||
ARCH=$(uname -m)
|
||||
|
||||
# Find all dropshell-tool.ARCH files in output/
|
||||
TOOLS=()
|
||||
@ -33,7 +39,7 @@ function publish_executables() {
|
||||
fi
|
||||
|
||||
for TOOL in "${TOOLS[@]}"; do
|
||||
echo "Publishing $TOOL"
|
||||
publish_tool "$TOOL" "${TOOL//dropshell-tool./}"
|
||||
|
||||
# extract the architecture from the tool name
|
||||
ARCH="${TOOL//dropshell-tool./}"
|
||||
@ -44,7 +50,17 @@ function publish_executables() {
|
||||
|
||||
}
|
||||
|
||||
publish_install
|
||||
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"
|
@ -5,4 +5,4 @@ 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"
|
||||
"${SCRIPT_DIR}/sos" upload "getbin.xyz" "${SCRIPT_DIR}/sos" "sos:latest"
|
||||
|
35
sos/sos
35
sos/sos
@ -15,10 +15,10 @@ function show_help() {
|
||||
sos is a script to upload files to a simple object storage server.
|
||||
|
||||
Usage:
|
||||
sos upload <server> <label:tag> <file>
|
||||
sos upload <server> <file> <label:tag> [label:tag ...]
|
||||
|
||||
Example:
|
||||
sos upload tools.dropshell.app file:latest ./file.txt
|
||||
sos upload tools.dropshell.app ./file.txt file:latest
|
||||
|
||||
This will upload the file to the server, and return the download URL.
|
||||
|
||||
@ -42,15 +42,25 @@ function datetime() {
|
||||
|
||||
|
||||
function upload() {
|
||||
if [ "$#" -ne 3 ]; then
|
||||
echo "Usage: sos upload <server> <label:tag> <file>"
|
||||
if [ "$#" -lt 3 ]; then
|
||||
echo "Usage: sos upload <server> <file> <label:tag> [label:tag ...]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
server=$1
|
||||
label=$2
|
||||
file=$3
|
||||
file=$2
|
||||
first_label=$3
|
||||
LABELTAGS=("$first_label")
|
||||
[[ "$first_label" =~ : ]] || die "Label $first_label does not contain a tag!"
|
||||
|
||||
shift 3
|
||||
for label in "$@"; do
|
||||
[[ "$label" =~ : ]] || die "Label $label does not contain a tag!"
|
||||
LABELTAGS+=("$label")
|
||||
done
|
||||
|
||||
# check if file contains :
|
||||
[[ ! "$file" =~ : ]] || die "File contains : - this is not allowed!"
|
||||
[ -f "$file" ] || die "File not found: $file"
|
||||
|
||||
|
||||
@ -60,15 +70,6 @@ function upload() {
|
||||
|
||||
DATETIME=$(datetime)
|
||||
|
||||
# if the label doesn't have a tag, add :lastest
|
||||
[[ "$label" =~ : ]] || label="$label:latest"
|
||||
label_base=$(echo "$label" | cut -d':' -f1)
|
||||
|
||||
LABELTAGS=(
|
||||
"$label"
|
||||
"$label_base:$DATETIME"
|
||||
"$label_base:latest"
|
||||
)
|
||||
# deduplicate the labeltags
|
||||
mapfile -t LABELTAGS < <(printf "%s\n" "${LABELTAGS[@]}" | sort -u)
|
||||
LABELTAGS_JSON=$(printf '"%s",' "${LABELTAGS[@]}")
|
||||
@ -104,7 +105,7 @@ EOF
|
||||
echo " "
|
||||
echo " "
|
||||
|
||||
JSON1=$(eval "curl -s \"https://$server/hash/$label\"")
|
||||
JSON1=$(eval "curl -s \"https://$server/hash/$first_label\"")
|
||||
HASH=$(echo "$JSON1" | jq -r '.hash')
|
||||
|
||||
JSON2=$(eval "curl -s \"https://$server/meta/$HASH\"") || die "Failed to get meta for $HASH"
|
||||
@ -115,7 +116,7 @@ EOF
|
||||
|
||||
echo " "
|
||||
|
||||
echo "Download URL: https://$server/$label > $FILENAME"
|
||||
echo "Download URL: https://$server/$first_label > $FILENAME"
|
||||
echo "Alternative: https://$server/$HASH > $FILENAME"
|
||||
}
|
||||
|
||||
|
@ -4,4 +4,5 @@ set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
"${SCRIPT_DIR}/sos" upload "getbin.xyz" "sos:test" "${SCRIPT_DIR}/sos"
|
||||
"${SCRIPT_DIR}/sos" upload "getbin.xyz" "${SCRIPT_DIR}/sos" "sos:test" "sos:dodgy"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user