added bash script that uses openssl in place of curl
authorfrrobert2 <frrobert@stnectarios.org>
Sun, 9 May 2021 19:24:12 +0000 (15:24 -0400)
committerfrrobert2 <frrobert@stnectarios.org>
Sun, 9 May 2021 19:24:12 +0000 (15:24 -0400)
notificatorossl [new file with mode: 0755]

diff --git a/notificatorossl b/notificatorossl
new file mode 100755 (executable)
index 0000000..bcd142b
--- /dev/null
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+# notifitcatorossl is a fork of https://github.com/ThatsRedacted/StationNotifier
+# This program uses openssl rather than curl to connect to a gemini site`
+
+key='/home/frrobert/.config/amfora/7debbb3fae40dbe77746aa465300febaec5abb778faa8a550f8e5924f0977983.key'
+cert='/home/frrobert/.config/amfora/7debbb3fae40dbe77746aa465300febaec5abb778faa8a550f8e5924f0977983.crt'
+connectto=30
+
+tmpfile=$(mktemp /tmp/not.XXXXXX)
+                url="gemini://station.martinrue.com/frrobert"
+lasttime=0
+trap ctrl_c INT
+function ctrl_c() {
+rm -f $tmpfile
+exit 0
+}
+while [ true ]
+do
+               if [[ "$url" != *://* ]];then
+                       domain="$url"
+                       url="gemini://$url"
+               else
+                               domain=$(sed 's/gemini:\/\///' <<< "$url")
+                       fi
+                       if [[ "$url" != *.*/*.* ]] && [[ $url != */ ]];then
+                               url="$url/"
+                       fi
+                       domain=$(sed 's/\/.*$//' <<< "$domain")
+                       timeout $connectto openssl s_client -crlf -quiet -key $key -cert $cert -connect "$domain:1965" <<<"$url" 2>/dev/null >> $tmpfile
+           
+               
+               
+               IFS=' ' read -ra my_array <<< $(cat $tmpfile | grep '/notifications')
+    notifications=${my_array[2]}
+    echo "" > $tmpfile
+    if [[ $notifications -gt $lasttime ]]; then
+        echo -en "\007"
+        echo "You have new notifications!"
+        read -p "Press enter to continue or amfora to go to notifications" answer
+       case $answer in
+               amfora) $(amfora gemini://station.martinrue.com/frrobert)
+                       ;;
+       esac
+
+        lasttime=$notifications
+        unset my_array
+    fi
+    sleep 60
+done
+