Difference between revisions of "Check nuki.sh"

From wikieduonline
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{lc}}
 
{{lc}}
  
 
+
<pre>
 
  #!/bin/bash
 
  #!/bin/bash
 
  OUTAGE=$(curl -m 10 https://status.nuki.io/en/ 2>&1 | grep -iwo outage  | uniq);
 
  OUTAGE=$(curl -m 10 https://status.nuki.io/en/ 2>&1 | grep -iwo outage  | uniq);
Line 17: Line 17:
 
  }
 
  }
 
   
 
   
   if [[ $OUTAGE="Outage" ]]; then
+
   if [[ "$OUTAGE" == "Outage" ]]; then
 
     echo "Nuki is currently experiencing an outage"; send_email; else echo "Nuki is currently operating normally";
 
     echo "Nuki is currently experiencing an outage"; send_email; else echo "Nuki is currently operating normally";
 
   fi
 
   fi
  
 
+
</pre>
  
  
Line 27: Line 27:
 
  [[Send email]]
 
  [[Send email]]
 
  [[Sign in with app passwords]]
 
  [[Sign in with app passwords]]
 +
[[crontab -e]]:
 +
:<code>* */15 * * * [[/usr/local/bin/]]check_nuki.sh | [[tee -a]] [[/var/log/]]check_nuki.log</code>
  
  
{{Swaks}}
+
== See also ==
 
+
* {{Swaks}}
 +
* {{Nuki}}
  
{{Nuki}}
+
[[Category:Bash]]

Latest revision as of 14:44, 19 November 2024

 #!/bin/bash
 OUTAGE=$(curl -m 10 https://status.nuki.io/en/ 2>&1 | grep -iwo outage  | uniq);
 
 EMAIL="[email protected]"
 PASS="[[yourappgeneratedpassword]]"
 
 send_email () {
 
   swaks -4 --server smtp.gmail.com -tlsc --tls-protocol TLSv1_2 \
     --from $EMAIL --to $EMAIL \
     --auth LOGIN --auth-user $EMAIL --auth-password "$PASS" -apt \
     --h-Subject '[KO] NUKI is currently experiencing an outage' --body 'Check NUKI' 
 
 }
 
  if [[ "$OUTAGE" == "Outage" ]]; then
     echo "Nuki is currently experiencing an outage"; send_email; else echo "Nuki is currently operating normally";
  fi


apt install swaks
Send email
Sign in with app passwords
crontab -e: 
* */15 * * * /usr/local/bin/check_nuki.sh | tee -a /var/log/check_nuki.log


See also[edit]

Advertising: