diff --git a/dropshell-build/install_dropshell_build_host.sh b/dropshell-build/install_dropshell_build_host.sh index ca24aa3..964c52d 100755 --- a/dropshell-build/install_dropshell_build_host.sh +++ b/dropshell-build/install_dropshell_build_host.sh @@ -80,12 +80,12 @@ function install_packages() { case $OS in "Ubuntu"|"Debian GNU/Linux") # Common packages for both Ubuntu and Debian - PACKAGES="build-essential cmake git wget tar curl ninja-build mold nodejs npm" + PACKAGES="build-essential cmake git wget tar curl ninja-build mold nodejs npm perl" INSTALLCMD="apt-get install -y" UPDATECMD="apt-get update" ;; "Alpine Linux") - PACKAGES="build-base cmake git wget tar curl ninja mold nodejs npm linux-headers" + PACKAGES="build-base cmake git wget tar curl ninja mold nodejs npm linux-headers perl" INSTALLCMD="apk add --no-cache" UPDATECMD="apk update" ;; diff --git a/dropshell-tool/src/GetbinClient.cpp b/dropshell-tool/src/GetbinClient.cpp index 531b3a5..1660044 100644 --- a/dropshell-tool/src/GetbinClient.cpp +++ b/dropshell-tool/src/GetbinClient.cpp @@ -11,7 +11,7 @@ using json = nlohmann::json; -static constexpr const char* SERVER_HOST = "getbin.xyz"; +static constexpr const char* SERVER_HOST = "tools.dropshell.app"; GetbinClient::GetbinClient() {} diff --git a/dropshell-tool/src/main.cpp b/dropshell-tool/src/main.cpp index f6c48ae..79c5083 100644 --- a/dropshell-tool/src/main.cpp +++ b/dropshell-tool/src/main.cpp @@ -9,10 +9,10 @@ - creates the ~/.local/bin/dropshell-tool directory, if it does not exist - removes the tool from the user's system if it is already installed, and the tool's entries in the ~/.bashrc_dropshell_tool script - - downloads the tool archive (tgz) from getbin.xyz (tool_name:ARCH), where ARCH is the architecture of the user's system, and unpacks it to the new tool directory: ~/.local/bin/dropshell-tool// + - downloads the tool archive (tgz) from tools.dropshell.app (tool_name:ARCH), where ARCH is the architecture of the user's system, and unpacks it to the new tool directory: ~/.local/bin/dropshell-tool// - sets the PATH to include the tool directory, by modifying the ~/.bashrc_dropshell_tool script - adds an entry for autocompletion for the tool to the ~/.bashrc_dropshell_tool script, where autocomplete just runs autocomplete - - creates a ~/.config/dropshell-tool/tool_name.json file, which contains the tool's name, version (by running version), hash from getbin.xyz, and architecture + - creates a ~/.config/dropshell-tool/tool_name.json file, which contains the tool's name, version (by running version), hash from tools.dropshell.app, and architecture - reads the json file from the tgz called dropshell-tool-config.json: - for each alias in the aliases array: - check if another command is using the alias, and continue only if not @@ -22,13 +22,13 @@ dropshell-tool publish - checks that dropshell-tool-config.json exists in the folder, and is valid (see above) - - creates a tgz archive of the folder, and uploads it to getbin.xyz's simple object storage server. + - creates a tgz archive of the folder, and uploads it to tools.dropshell.app's simple object storage server. - prints the URL and hash of the uploaded archive - - uses the token ~/.config/getbin.xyz/write_token.txt, or prompts the user for a token if it is not found and writes it to the file + - uses the token ~/.config/tools.dropshell.app/write_token.txt, or prompts the user for a token if it is not found and writes it to the file dropshell-tool update - - compares the hash from the ~/.config/dropshell-tool/tool_name.json file with the hash from getbin.xyz (tool_name:ARCH), and continues only if they are different - - checks the version from the ~/.config/dropshell-tool/tool_name.json file with the version from getbin.xyz (tool_name:ARCH), and continues only if the remote version is newer (installed is older) + - compares the hash from the ~/.config/dropshell-tool/tool_name.json file with the hash from tools.dropshell.app (tool_name:ARCH), and continues only if they are different + - checks the version from the ~/.config/dropshell-tool/tool_name.json file with the version from tools.dropshell.app (tool_name:ARCH), and continues only if the remote version is newer (installed is older) - installs the tool as per the install command dropshell-tool update all @@ -181,13 +181,13 @@ int publish_tool(int argc, char* argv[]) { std::cerr << "Failed to create archive." << std::endl; return 1; } - std::filesystem::path tokenPath = std::filesystem::path(home) / ".config/getbin.xyz/write_token.txt"; + std::filesystem::path tokenPath = std::filesystem::path(home) / ".config/tools.dropshell.app/write_token.txt"; std::string token; if (std::filesystem::exists(tokenPath)) { std::ifstream tfile(tokenPath); std::getline(tfile, token); } else { - std::cout << "Enter getbin.xyz write token: "; + std::cout << "Enter tools.dropshell.app write token: "; std::getline(std::cin, token); std::filesystem::create_directories(tokenPath.parent_path()); std::ofstream tfile(tokenPath); diff --git a/install.sh b/install.sh deleted file mode 100644 index ba147de..0000000 --- a/install.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - - -# install dropshell-tools! diff --git a/sos/sos b/sos/sos new file mode 100755 index 0000000..635a738 --- /dev/null +++ b/sos/sos @@ -0,0 +1,79 @@ +#!/bin/bash + +set -euo pipefail + +# sos upload + +# example: +# sos upload tools.dropshell.app file:latest ./file.txt + +# this will upload the file to the server, and return the download URL + + +function show_help() { + cat << EOF + + sos is a script to upload files to a simple object storage server. + +Usage: + sos upload + +Example: + sos upload tools.dropshell.app file:latest ./file.txt + +This will upload the file to the server, and return the download URL +EOF + exit 0 +} + +function die() { + echo "$@" + exit 1 +} + + +function upload() { + if [ "$#" -ne 3 ]; then + echo "Usage: sos upload " + exit 1 + fi + + server=$1 + label=$2 + file=$3 + + [ -f "$file" ] || die "File not found: $file" + + # if the label doesn't have a tag, add :lastest + if [[ ! "$label" =~ : ]]; then + label="$label:latest" + fi + + # upload the file + echo "Uploading $file to $server - $label..." + + METADATA="{\"labeltags\":[\"$label\"],\"description\":\"Uploaded by sos\"}" + + HASH="" + JSON=$(curl -s -X POST -F "file=@$file" -F "metadata=$METADATA" "https://$server/$label") || die "Failed to upload $file to $server - $label" + HASH=$(echo "$JSON" | jq -r '.hash') + JSON2=$(curl -s "https://$server/meta/$HASH") || die "Failed to get meta for $HASH" + FILENAME=$(echo "$JSON2" | jq -r '.filename') + + echo "Download URL: https://$server/$label > $FILENAME" + echo "Alternative: https://$server/$HASH > $FILENAME" + echo "Hash: $HASH" +} + +# if no arguments, show help +[ "$#" -gt 0 ] || show_help + +CMD="$1" +shift + +if [ "$CMD" == "upload" ]; then + upload "$@" + exit $? +fi + +die "Unknown command: $CMD"