aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorU-AD\carlsoan <carlsoan@gophersjos7275.ad.uc.edu>2018-05-30 10:40:37 -0400
committerU-AD\carlsoan <carlsoan@gophersjos7275.ad.uc.edu>2018-05-30 10:40:37 -0400
commitfae0ad6c10a80413ecf11c674adad6209d5748d6 (patch)
tree627c414ebb6b35350e819432ef41f4d145908b5e
parent5b8e26035915fe9fe3f5cb045e3ec80b617236b8 (diff)
Added PHP5/7 checks
-rw-r--r--README.md5
-rwxr-xr-xchecks/php5check.sh.m435
-rwxr-xr-xchecks/php7check.sh.m435
3 files changed, 74 insertions, 1 deletions
diff --git a/README.md b/README.md
index a704d1d..816784e 100644
--- a/README.md
+++ b/README.md
@@ -23,4 +23,7 @@ Send software version release data to IFTTT webhooks
| Net-SNMP | snmpversion |
| OpenSSH | sshversion |
| OpenSSL | sslversion |
-| Core Linux | tcversion |
+| Core Linux | tcversion |
+| PHP 5 | php5version |
+| PHP 7 | php7version |
+
diff --git a/checks/php5check.sh.m4 b/checks/php5check.sh.m4
new file mode 100755
index 0000000..57d81af
--- /dev/null
+++ b/checks/php5check.sh.m4
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+##############################
+# sends the follows JSON to webhook:
+#
+# { "value1":"<php5-version>" }
+##############################
+
+CHECKDIR="BASEDIR"
+CONFDIR="$CHECKDIR/conf"
+
+IFTTTKEY="KEYTEXT"
+
+php5versiondata() {
+ curl -s http://php.net/downloads.php 2>/dev/null | \
+ grep -A1 'Current Stable' | awk '/^[ \t]*PHP 5/ { print $2 }'
+}
+
+if [ "$1" == "cache" ]; then
+ php5versiondata > $CONFDIR/php5ver
+else
+ if [ ! -f $CONFDIR/php5ver ]; then
+ echo "Caching PHP 5 version"
+ $0 cache
+ else
+ php5versiondata > /tmp/php5ver
+ diff /tmp/php5ver $CONFDIR/php5ver
+ if [ $? -eq 1 ] && [ $(grep '^[ \t]*$' /tmp/php5ver | wc -l) -eq 0 ]; then
+ mv /tmp/php5ver $CONFDIR/php5ver
+ echo "{\"value1\":\"$(cat $CONFDIR/php5ver)\"}" |curl -X POST -d ''"$(cat -)"'' -H "Content-type: application/json" https://maker.ifttt.com/trigger/{php5version}/with/key/$IFTTTKEY
+ else
+ echo "skipping"
+ fi
+ fi
+fi
diff --git a/checks/php7check.sh.m4 b/checks/php7check.sh.m4
new file mode 100755
index 0000000..2992e1c
--- /dev/null
+++ b/checks/php7check.sh.m4
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+##############################
+# sends the follows JSON to webhook:
+#
+# { "value1":"<php7-version>" }
+##############################
+
+CHECKDIR="BASEDIR"
+CONFDIR="$CHECKDIR/conf"
+
+IFTTTKEY="KEYTEXT"
+
+php7versiondata() {
+ curl -s http://php.net/downloads.php 2>/dev/null | \
+ grep -A1 'Current Stable' | awk '/^[ \t]*PHP 7/ { print $2 }'
+}
+
+if [ "$1" == "cache" ]; then
+ php7versiondata > $CONFDIR/php7ver
+else
+ if [ ! -f $CONFDIR/php7ver ]; then
+ echo "Caching PHP 7 version"
+ $0 cache
+ else
+ php7versiondata > /tmp/php7ver
+ diff /tmp/php7ver $CONFDIR/php7ver
+ if [ $? -eq 1 ] && [ $(grep '^[ \t]*$' /tmp/php7ver | wc -l) -eq 0 ]; then
+ mv /tmp/php7ver $CONFDIR/php7ver
+ echo "{\"value1\":\"$(cat $CONFDIR/php7ver)\"}" |curl -X POST -d ''"$(cat -)"'' -H "Content-type: application/json" https://maker.ifttt.com/trigger/{php7version}/with/key/$IFTTTKEY
+ else
+ echo "skipping"
+ fi
+ fi
+fi