blob: 7432e430aa7e57e6c35c91318591a4499a198903 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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;
|