:-'Generic Commit'

This commit is contained in:
Your Name 2025-05-29 23:07:07 +12:00
parent 7b6b89c5d9
commit fc4096d649
5 changed files with 90 additions and 15 deletions

View File

@ -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"
;;

View File

@ -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() {}

View File

@ -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/<tool_name>/
- 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/<tool_name>/
- 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 <tool_name> autocomplete <args>
- creates a ~/.config/dropshell-tool/tool_name.json file, which contains the tool's name, version (by running <tool_name> 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 <tool_name> 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 <tool_name:ARCH> <folder>
- 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 <tool_name>
- 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);

View File

@ -1,4 +0,0 @@
#!/bin/bash
# install dropshell-tools!

79
sos/sos Executable file
View File

@ -0,0 +1,79 @@
#!/bin/bash
set -euo pipefail
# sos upload <server> <label:tag> <file>
# 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 <server> <label:tag> <file>
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 <server> <label:tag> <file>"
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"