File size: 1,301 Bytes
646cee8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/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