#!/bin/bash # Variables FILE_PATH="/etc/searxng/settings.yml" # Path to the file you want to monitor NEKOBIN_API="https://nekobin.com/api/documents" # Nekobin API endpoint CHECK_INTERVAL=10 # Time (in seconds) between checks # Function to check if the file exists and upload its content to Nekobin function upload_to_nekobin() { while true; do # Check if the file exists if [ -f "$FILE_PATH" ]; then echo "File found! Uploading to Nekobin..." # Upload the content of the file to Nekobin and get the response response=$(curl -s -X POST -d "{\"content\": \"$(cat "$FILE_PATH")\"}" -H "Content-Type: application/json" $NEKOBIN_API) # Extract the key from the JSON response key=$(echo "$response" | grep -o '"key":"[^"]*' | grep -o '[^"]*$') # Construct the URL url="https://nekobin.com/$key" echo "File uploaded successfully. You can view it at: $url" # Exit after successful upload break else echo "File not found. Checking again in $CHECK_INTERVAL seconds..." fi # Wait before checking again sleep $CHECK_INTERVAL done } # Start monitoring for the file and upload once it exists upload_to_nekobin