From 1733e5fe839caff338a664a39208599afe8df42b Mon Sep 17 00:00:00 2001 From: "Jason D. McCormick" Date: Tue, 14 Apr 2020 21:06:28 -0400 Subject: adding the big red button stuff --- allstar/allstar-restart | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 allstar/allstar-restart (limited to 'allstar/allstar-restart') 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; -- cgit v1.2.3