first commit. gotifypush script
This commit is contained in:
		
						commit
						21ee1aa54c
					
				
							
								
								
									
										7
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
			
		||||
# Bash Scripts collection
 | 
			
		||||
 | 
			
		||||
## gotifypush.sh
 | 
			
		||||
 | 
			
		||||
Send markdown notifications to gotify channel throught curl
 | 
			
		||||
 | 
			
		||||
`Usage: ./gotifypush.sh <title> <message> <priority> <token> <clickurl>`
 | 
			
		||||
							
								
								
									
										23
									
								
								gotifypush.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								gotifypush.sh
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
#Use ./gotifypush <title> <message> <priority> <token> <clickurl>
 | 
			
		||||
 | 
			
		||||
#uncomment when use script from cron
 | 
			
		||||
PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
 | 
			
		||||
 | 
			
		||||
# Gotify notification parameters
 | 
			
		||||
TITLE=$1
 | 
			
		||||
MESSAGE=$2
 | 
			
		||||
PRIORITY=$3
 | 
			
		||||
URL="https://push.example.com/message?token=$4"
 | 
			
		||||
#if url passed by parameter, set to extras
 | 
			
		||||
if [ -n "$5" ]
 | 
			
		||||
then
 | 
			
		||||
        EXTRAS="{\"client::display\": {\"contentType\": \"text/markdown\"}, \"client::notification\": {\"click\": {  \"url\": \"$5\"}}}"
 | 
			
		||||
else
 | 
			
		||||
        EXTRAS="{\"client::display\": {\"contentType\": \"text/markdown\"}}"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# better curl usage https://github.com/gotify/server/issues/68
 | 
			
		||||
#curl --silent --output /dev/null --show-error --fail -X .... #silent curl execution, no output, only html code if error
 | 
			
		||||
curl -X POST "${URL}" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"message\": \"${MESSAGE}\", \"priority\": ${PRIORITY}, \"title\": \"${TITLE}\", \"extras\": ${EXTRAS} }"
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user