Save SenderName || SenderIP per message

This commit is contained in:
2022-11-29 11:07:15 +01:00
parent 464cf3ec7e
commit ac9ae06cc8
14 changed files with 114 additions and 317 deletions

View File

@@ -30,6 +30,7 @@ curl \
--data "msg_id=$(uuidgen)" \
--data "timestamp=$(date +%s)" \
--data "channel={channel_name}" \
--data "sender_name=$(hostname)" \
{{config|baseURL}}/</pre>
<p>Most parameters are optional, you can send a message with only a title (default priority and channel will be used)</p>
<pre>

View File

@@ -41,8 +41,9 @@ usage<span style="color: #f92672">()</span> <span style="color: #f92672">{</span
<span style="color: #f8f8f2">content</span><span style="color: #f92672">=</span><span style="color: #e6db74">&quot;&quot;</span>
<span style="color: #f8f8f2">channel</span><span style="color: #f92672">=</span><span style="color: #e6db74">&quot;&quot;</span>
<span style="color: #f8f8f2">priority</span><span style="color: #f92672">=</span>1
<span style="color: #f8f8f2">usr_msg_id</span><span style="color: #f92672">=</span><span style="color: #66d9ef">$(</span>uuidgen<span style="color: #66d9ef">)</span>
<span style="color: #f8f8f2">sendtime</span><span style="color: #f92672">=</span><span style="color: #66d9ef">$(</span>date +%s<span style="color: #66d9ef">)</span>
<span style="color: #f8f8f2">usr_msg_id</span><span style="color: #f92672">=</span><span style="color: #e6db74">&quot;$(uuidgen)&quot;</span>
<span style="color: #f8f8f2">sendtime</span><span style="color: #f92672">=</span><span style="color: #e6db74">&quot;$(date +%s)&quot;</span>
<span style="color: #f8f8f2">sender</span><span style="color: #f92672">=</span><span style="color: #e6db74">&quot;$(hostname)&quot;</span>
<span style="color: #66d9ef">if</span> <span style="color: #f92672">[</span> <span style="color: #66d9ef">${#</span><span style="color: #f8f8f2">args[@]</span><span style="color: #66d9ef">}</span> -lt 1 <span style="color: #f92672">]</span>; <span style="color: #66d9ef">then</span>
<span style="color: #66d9ef"> </span><span style="color: #f8f8f2">echo</span> <span style="color: #e6db74">&quot;[ERROR]: no title supplied via parameter&quot;</span> 1&gt;&amp;2
@@ -64,7 +65,6 @@ usage<span style="color: #f92672">()</span> <span style="color: #f92672">{</span
<span style="color: #f8f8f2">title</span><span style="color: #f92672">=</span><span style="color: #e6db74">&quot;${args[0]}&quot;</span>
<span style="color: #f8f8f2">content</span><span style="color: #f92672">=</span><span style="color: #e6db74">&quot;&quot;</span>
<span style="color: #f8f8f2">sendtime</span><span style="color: #f92672">=</span><span style="color: #66d9ef">$(</span>date +%s<span style="color: #66d9ef">)</span>
<span style="color: #66d9ef">if</span> <span style="color: #f92672">[</span> <span style="color: #66d9ef">${#</span><span style="color: #f8f8f2">args[@]</span><span style="color: #66d9ef">}</span> -gt 1 <span style="color: #f92672">]</span>; <span style="color: #66d9ef">then</span>
<span style="color: #66d9ef"> </span><span style="color: #f8f8f2">content</span><span style="color: #f92672">=</span><span style="color: #e6db74">&quot;${args[0]}&quot;</span>
@@ -96,6 +96,7 @@ usage<span style="color: #f92672">()</span> <span style="color: #f92672">{</span
--data <span style="color: #e6db74">&quot;priority=$priority&quot;</span> <span style="color: #ae81ff">\</span>
--data <span style="color: #e6db74">&quot;msg_id=$usr_msg_id&quot;</span> <span style="color: #ae81ff">\</span>
--data <span style="color: #e6db74">&quot;channel=$channel&quot;</span> <span style="color: #ae81ff">\</span>
--data <span style="color: #e6db74">&quot;sender_name=$sender&quot;</span> <span style="color: #ae81ff">\</span>
<span style="color: #e6db74">&quot;https://scn.blackforestbytes.com/&quot;</span> <span style="color: #66d9ef">)</span>
<span style="color: #66d9ef">if</span> <span style="color: #f92672">[</span> <span style="color: #e6db74">&quot;$curlresp&quot;</span> <span style="color: #f92672">==</span> 200 <span style="color: #f92672">]</span> ; <span style="color: #66d9ef">then</span>
@@ -132,5 +133,6 @@ usage<span style="color: #f92672">()</span> <span style="color: #f92672">{</span
<span style="color: #f8f8f2">echo</span> <span style="color: #e6db74">&quot;Send failed (response code $curlresp) ... try again in 5s&quot;</span> 1&gt;&amp;2
sleep 5
<span style="color: #66d9ef">done</span>
</pre>

View File

@@ -41,8 +41,9 @@ title=$1
content=<span style="color: #0000FF">&quot;&quot;</span>
channel=<span style="color: #0000FF">&quot;&quot;</span>
priority=1
usr_msg_id=<span style="color: #000080; font-weight: bold">$(</span>uuidgen<span style="color: #000080; font-weight: bold">)</span>
sendtime=<span style="color: #000080; font-weight: bold">$(</span>date +%s<span style="color: #000080; font-weight: bold">)</span>
usr_msg_id=<span style="color: #0000FF">&quot;$(uuidgen)&quot;</span>
sendtime=<span style="color: #0000FF">&quot;$(date +%s)&quot;</span>
sender=<span style="color: #0000FF">&quot;$(hostname)&quot;</span>
<span style="color: #000080; font-weight: bold">if</span> [ <span style="color: #000080; font-weight: bold">${#</span>args[@]<span style="color: #000080; font-weight: bold">}</span> -lt 1 ]; <span style="color: #000080; font-weight: bold">then</span>
<span style="color: #000080; font-weight: bold"> </span>echo <span style="color: #0000FF">&quot;[ERROR]: no title supplied via parameter&quot;</span> 1&gt;&amp;2
@@ -64,7 +65,6 @@ sendtime=<span style="color: #000080; font-weight: bold">$(</span>date +%s<span
title=<span style="color: #0000FF">&quot;${args[0]}&quot;</span>
content=<span style="color: #0000FF">&quot;&quot;</span>
sendtime=<span style="color: #000080; font-weight: bold">$(</span>date +%s<span style="color: #000080; font-weight: bold">)</span>
<span style="color: #000080; font-weight: bold">if</span> [ <span style="color: #000080; font-weight: bold">${#</span>args[@]<span style="color: #000080; font-weight: bold">}</span> -gt 1 ]; <span style="color: #000080; font-weight: bold">then</span>
<span style="color: #000080; font-weight: bold"> </span>content=<span style="color: #0000FF">&quot;${args[0]}&quot;</span>
@@ -96,6 +96,7 @@ sendtime=<span style="color: #000080; font-weight: bold">$(</span>date +%s<span
--data <span style="color: #0000FF">&quot;priority=$priority&quot;</span> <span style="color: #0000FF">\</span>
--data <span style="color: #0000FF">&quot;msg_id=$usr_msg_id&quot;</span> <span style="color: #0000FF">\</span>
--data <span style="color: #0000FF">&quot;channel=$channel&quot;</span> <span style="color: #0000FF">\</span>
--data <span style="color: #0000FF">&quot;sender_name=$sender&quot;</span> <span style="color: #0000FF">\</span>
<span style="color: #0000FF">&quot;https://scn.blackforestbytes.com/&quot;</span> <span style="color: #000080; font-weight: bold">)</span>
<span style="color: #000080; font-weight: bold">if</span> [ <span style="color: #0000FF">&quot;$curlresp&quot;</span> == 200 ] ; <span style="color: #000080; font-weight: bold">then</span>