summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason D. McCormick <jason@mfamily.org>2020-04-14 21:06:28 -0400
committerJason D. McCormick <jason@mfamily.org>2020-04-14 21:06:28 -0400
commit1733e5fe839caff338a664a39208599afe8df42b (patch)
treec15a80d60a818cfe9a0fc8dc64ac092cc5511de3
parent820a97dcdd2a7c5bc6ae8bf5798578caa87ee77f (diff)
adding the big red button stuff
-rwxr-xr-xallstar/allstar-brb22
-rwxr-xr-xallstar/allstar-restart30
-rwxr-xr-xallstar/brb21
-rw-r--r--allstar/brb.html30
4 files changed, 103 insertions, 0 deletions
diff --git a/allstar/allstar-brb b/allstar/allstar-brb
new file mode 100755
index 0000000..294e73c
--- /dev/null
+++ b/allstar/allstar-brb
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+if [ -f /var/lib/asterisk/brb/pressed ]; then
+ /usr/local/bin/allstar-restart
+
+ /usr/bin/ssmtp -t <<EOM
+From: Asterisk <root@megalink.network>
+To: zabbix@megalink.network
+Subject: Big Red Button Pushed - $(hostname)
+
+This is the allstar-brb program on $(hostname)
+
+Asterisk was cycled at:
+
+$(date)
+
+due to someone pushing the big red button!
+
+Be will, John Spartan
+EOM
+
+fi
diff --git a/allstar/allstar-restart b/allstar/allstar-restart
new file mode 100755
index 0000000..7432e43
--- /dev/null
+++ b/allstar/allstar-restart
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+
+use strict;
+
+use File::Temp qw/tempfile/;
+use Sys::Hostname;
+
+my $host = hostname;
+
+# The init script for asterisk is really weak. Find
+# all of the pids that are child pids of the
+# safe_asterisk process which is launched as a nohup
+# process rooted in /bin/sh. The astdn.sh script
+# just does not work right at all to kill stuck children
+my $sapid = qx(/usr/bin/pgrep safe_asterisk);
+
+# be maximally safe and don't do anything if there is
+# no safe_asterisk process
+if( length($sapid) > 0 ){
+ my $apids = qx(/usr/bin/pstree -p $sapid);
+ $apids =~ s/[^\d]/ /g;
+ $apids =~ s/\s+/ /g;
+ system("/usr/bin/kill -9 $apids > /dev/null 2>&1");
+ sleep 1;
+ unlink "/var/run/asterisk.ctl";
+ unlink "/var/run/asterisk.pid";
+ system("/usr/local/sbin/astup.sh > /dev/null 2>&1");
+}
+
+exit 0;
diff --git a/allstar/brb b/allstar/brb
new file mode 100755
index 0000000..77c4577
--- /dev/null
+++ b/allstar/brb
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+
+ echo -e "Content-type: text/html\n\n"
+ echo "<html>"
+ echo "<head>"
+ echo "<title>Pressed the Big Red Button</title>"
+ echo "</head>"
+ echo "<body>"
+ echo -e "<center><h1>"
+
+if [ ! -f /var/lib/asterisk/brb/pressed ]; then
+ touch /var/lib/asterisk/brb/pressed
+ echo -e "CLICK"
+else
+ echo -e "PATIENCE GRASSHOPPER!"
+fi
+ echo -e "</center></h1>"
+ echo "</body>"
+ echo "</html>"
+exit 0;
diff --git a/allstar/brb.html b/allstar/brb.html
new file mode 100644
index 0000000..d2f0d3a
--- /dev/null
+++ b/allstar/brb.html
@@ -0,0 +1,30 @@
+<html>
+<head>
+<title>The Big Red Button</title>
+</head>
+<style>
+ .button {
+ background-color: #FF0000;
+ color: #FFFFFF;
+ padding: 10px;
+ border-radius: 50px;
+ -moz-border-radius: 50px;
+ -webkit-border-radius: 50px;
+ margin:10px;
+ text-align: center;
+ font-size: 24px;
+ width: 200px;
+ height: 200px;
+ line-height: 200px;
+ }
+
+ a:link , a:visited , a:hover , a:active {
+ text-decoration: none;
+ }
+</style>
+<body>
+<center>
+<a href="/cgi-bin/brb"><div class="button">CLICK HERE</div></a>
+</center>
+</body>
+</html>