echo"Found a single asterisk instance running as process $pid"
if$RUNNING;then
fi
answer=Y
else
# More than 1 asterisk process running
read-p"WARNING: Taking a core dump of the running asterisk instance will suspend call processing while the dump is saved. Do you wish to continue? (y/N) " answer
if[ x"$pid"= x ];then
# More than 1 process running, let's try asking asterisk for it's
# pidfile
pidfile=$("$asterisk_bin"-rx"core show settings" 2>/dev/null | sed-n-r-e"s/^\s*pid file:\s+(.*)/\1/gpi")
# We found it
if[ x"$pidfile"!= x -a-f"$pidfile"];then
pid=$(cat"$pidfile")
echo"Found pidfile $pidfile with process $pid"
fi
fi
if[["$answer"=~ ^[Yy] ]];then
fi
cf="${OUTPUTDIR:-/tmp}/core-asterisk-running-$df"
echo"Dumping running asterisk process to $cf"
# It's possible that asterisk was started with the -C option which means the
pidfile=$("$asterisk_bin"-C"$astetcconf"-rx"core show settings" 2>/dev/null | sed-n-r-e"s/^\s*pid file:\s+(.*)/\1/gpi")
if[ x"$pidfile"!= x -a-f"$pidfile"];then
pid=$(cat"$pidfile")
echo"Found pidfile $pidfile the hard way with process $pid"
break
fi
fi
done
if[$mounted_proc-eq 1 ];then
echo"Unmounting /proc"
umount /proc
fi
fi
if[ x"$pid"= x ];then
>&2 echo"Can't determine pid of the running asterisk instance"
exit 1
fi
if$RUNNING;then
answer=Y
else
read-p"WARNING: Taking a core dump of the running asterisk instance will suspend call processing while the dump is saved. Do you wish to continue? (y/N) " answer