Add files via upload

This commit is contained in:
MachinePainting
2026-01-29 03:32:58 -08:00
committed by GitHub
parent 844cf8a809
commit a75c712ee1
2 changed files with 41 additions and 58 deletions
+17 -28
View File
@@ -1,18 +1,16 @@
#!/bin/bash
# DropSend Decryption Script for Linux
# ComfyUI Encryption Scripts - Decryption (Linux)
# Works with both DropSend and DriveSend nodes
# Decrypts .enc files using a key from environment variable or Secret Service
echo "=== DropSend File Decryption (Linux) ==="
echo "=== ComfyUI File Decryption (Linux) ==="
echo ""
echo "Enter the folder path containing .enc files:"
# Read folder path
read -r FOLDER
# Remove any surrounding quotes
FOLDER=$(echo "$FOLDER" | sed "s/^['\"]//;s/['\"]$//")
# Validate folder path
if [ -z "$FOLDER" ] || [ ! -d "$FOLDER" ]; then
echo "Error: '$FOLDER' is not a valid directory."
exit 1
@@ -21,7 +19,6 @@ fi
echo "Processing folder: $FOLDER"
echo ""
# Prompt for recursive option
echo "Would you like to decrypt files recursively (including subfolders)? (Y/N)"
read -r RECURSIVE_RESPONSE
if [[ "$RECURSIVE_RESPONSE" == "Y" || "$RECURSIVE_RESPONSE" == "y" ]]; then
@@ -30,28 +27,32 @@ else
RECURSIVE="false"
fi
# Try to get key from environment variable
echo ""
echo "Retrieving encryption key..."
KEY="${DROPSEND_ENCRYPTION_KEY:-}"
# Try multiple environment variable names for compatibility
KEY="${COMFYUI_ENCRYPTION_KEY:-}"
[ -z "$KEY" ] && KEY="${comfyui_encryption_key:-}"
[ -z "$KEY" ] && KEY="${DROPSEND_ENCRYPTION_KEY:-}"
[ -z "$KEY" ] && KEY="${DRIVESEND_ENCRYPTION_KEY:-}"
# If not in environment, try secret-tool (GNOME Keyring / KWallet)
# Try Secret Service with multiple names
if [ -z "$KEY" ] && command -v secret-tool &> /dev/null; then
KEY=$(secret-tool lookup service DropSend username DropSend 2>/dev/null)
KEY=$(secret-tool lookup service ComfyUI username ComfyUI 2>/dev/null)
[ -z "$KEY" ] && KEY=$(secret-tool lookup service DropSend username DropSend 2>/dev/null)
[ -z "$KEY" ] && KEY=$(secret-tool lookup service DriveSend username DriveSend 2>/dev/null)
if [ -n "$KEY" ]; then
echo "Using key from Secret Service (GNOME Keyring/KWallet)."
echo "Using key from Secret Service."
fi
fi
# If still no key, prompt user
if [ -z "$KEY" ]; then
echo ""
echo "Encryption key not found in environment or Secret Service."
echo ""
echo "To set up automatic key retrieval, either:"
echo " 1. Set environment variable: export DROPSEND_ENCRYPTION_KEY=\"your_key\""
echo " 2. Store with secret-tool: echo -n \"your_key\" | secret-tool store --label=\"DropSend\" service DropSend username DropSend"
echo " 1. Set environment variable: export COMFYUI_ENCRYPTION_KEY=\"your_key\""
echo " 2. Store with secret-tool: echo -n \"your_key\" | secret-tool store --label=\"ComfyUI\" service ComfyUI username ComfyUI"
echo ""
echo -n "Enter your encryption key: "
read -r KEY
@@ -66,7 +67,6 @@ fi
echo ""
# Python script to decrypt all .enc files
python3 - <<EOF
import os
import sys
@@ -86,7 +86,6 @@ def decrypt_file(encrypted_path, output_path, key):
print(f" ✗ Error decrypting {os.path.basename(encrypted_path)}: {e}")
return False
# Process .enc files
folder = "$FOLDER"
key = "$KEY"
recursive = "$RECURSIVE" == "true"
@@ -108,21 +107,14 @@ else:
enc_files.append(os.path.join(folder, file))
if not enc_files:
print("No .enc files found in the specified location.")
print("No .enc files found.")
sys.exit(0)
print(f"Found {len(enc_files)} .enc file(s) to decrypt.")
print("")
for enc_path in enc_files:
# Remove .enc extension to get original filename
base_name = enc_path[:-4] # Remove .enc
if not os.path.splitext(base_name)[1]:
# No extension found, default to .png
out_path = base_name + '.png'
else:
out_path = base_name
out_path = enc_path[:-4]
if decrypt_file(enc_path, out_path, key):
success_count += 1
else:
@@ -132,15 +124,12 @@ print("")
print(f"Decryption complete: {success_count} successful, {error_count} failed")
EOF
# Check if decryption was successful
if [ $? -ne 0 ]; then
echo "Error: Decryption process encountered an error."
exit 1
fi
echo ""
# Prompt to move .enc files
echo "Would you like to move all .enc files to a separate folder? (Y/N)"
read -r MOVE_RESPONSE
if [[ "$MOVE_RESPONSE" == "Y" || "$MOVE_RESPONSE" == "y" ]]; then