Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENHANCEMENT]: call URL only if everything is ok (for Uptime Kuma) #98

Open
andreapx opened this issue Apr 15, 2024 · 2 comments
Open
Labels
enhancement New feature or request to do

Comments

@andreapx
Copy link

I use Uptime Kuma that alerts me only if anything is wrong (a service is down, a backup fails, and so on).
What about integrate Uptime Kuma in the script (or just call an URL only when there are no errors/workings)?
Thanks!

@auanasgheps
Copy link
Owner

I could definitely integrate Uptime Kuma. Seems to be a popular service. (I don't know or use it, for this I use Healthchecks.io)

In the meantime, you can use the "hook notification" feature. It will do the job just fine.

https://github.com/auanasgheps/snapraid-aio-script/blob/e2377893e4923703325764cc5d759aa81cf11830/script-config.sh#L46C1-L55C21

@auanasgheps auanasgheps added enhancement New feature or request to do labels Apr 15, 2024
@andreapx
Copy link
Author

I could definitely integrate Uptime Kuma. Seems to be a popular service. (I don't know or use it, for this I use Healthchecks.io)

In the meantime, you can use the "hook notification" feature. It will do the job just fine.

https://github.com/auanasgheps/snapraid-aio-script/blob/e2377893e4923703325764cc5d759aa81cf11830/script-config.sh#L46C1-L55C21

I've tried with the hook notification putting there the URL, but it doesn't work. I've tried to create a bash script that by itself work, but when called from this script it fails saying that the URL is not valid. I'm not a developer and I'm not very familiar with scripts either, this has been created by Proximity AI.

#!/bin/bash

# Check if the required number of arguments is provided
if [ $# -ne 2 ]; then
  echo "Usage: $0 <param1> <param2>"
  exit 1
fi

# Store the command line arguments in variables
param1=$1
echo $param1
echo "**************************************************************************"
param2=$2
echo $param2

# URL encode the parameter values
encoded_param1=$(echo "$param1" | sed 's/ /%20/g' | sed 's/!/%21/g' | sed 's/"/%22/g' | sed 's/#/%23/g' | sed 's/\$/%24/g' | sed 's/\&/%26/g' | sed "s/'/%27/g" | sed 's/(/%28/g' | sed 's/)/%29/g' | sed 's/:/%3A/g' | sed 's/;/%3B/g' | sed 's/</%3C/g' | sed 's/=/%3D/g' | sed 's/>/%3E/g' | sed 's/?/%3F/g' | sed 's/@/%40/g' | sed 's/\[/%5B/g' | sed 's/\\/%5C/g' | sed 's/\]/%5D/g' | sed 's/\^/%5E/g' | sed 's/_/%5F/g' | sed 's/`/%60/g' | sed 's/{/%7B/g' | sed 's/|/%7C/g' | sed 's/}/%7D/g' | sed 's/~/%7E/g')
encoded_param2=$(echo "$param2" | sed 's/ /%20/g' | sed 's/!/%21/g' | sed 's/"/%22/g' | sed 's/#/%23/g' | sed 's/\$/%24/g' | sed 's/\&/%26/g' | sed "s/'/%27/g" | sed 's/(/%28/g' | sed 's/)/%29/g' | sed 's/:/%3A/g' | sed 's/;/%3B/g' | sed 's/</%3C/g' | sed 's/=/%3D/g' | sed 's/>/%3E/g' | sed 's/?/%3F/g' | sed 's/@/%40/g' | sed 's/\[/%5B/g' | sed 's/\\/%5C/g' | sed 's/\]/%5D/g' | sed 's/\^/%5E/g' | sed 's/_/%5F/g' | sed 's/`/%60/g' | sed 's/{/%7B/g' | sed 's/|/%7C/g' | sed 's/}/%7D/g' | sed 's/~/%7E/g')

encoded_param1=$(echo -n "$param1" | jq -sRr @uri)
encoded_param2=$(echo -n "$param2" | jq -sRr @uri)

echo " "
echo encoded_param1
echo "------------------------------"
echo encoded_param2
# Construct the URL with the encoded parameters
url="https://xxxxxxxxx.com/webhook-SnapRAID-script_bf2f4u9-1842FQ=gbu3&b3c8r136ifb683?param1=$encoded_param1&param2=$encoded_param2"

# Send the GET request using curl
response=$(curl -s -X GET "$url")

# Print the response
echo "Response: $response"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request to do
Projects
None yet
Development

No branches or pull requests

2 participants