2009-12-22 15:06:10 -05:00
|
|
|
#!/bin/sh
|
2009-10-12 18:22:52 -04:00
|
|
|
|
|
|
|
arg=$1
|
|
|
|
shift
|
|
|
|
|
2010-02-01 10:29:40 -05:00
|
|
|
if [ -f "config.status" ] ; then
|
|
|
|
prefix=$(cat config.status | grep @prefix@ | awk -F, '{print $3}')
|
|
|
|
fi
|
|
|
|
if [ -f "config.status" -a -z "$prefix" ] ; then
|
2009-11-11 22:46:43 -05:00
|
|
|
prefix=$(cat config.status | grep '"prefix"' | awk -F\" '{print $4}')
|
|
|
|
fi
|
2009-10-12 18:22:52 -04:00
|
|
|
|
2010-02-01 10:29:40 -05:00
|
|
|
if [ -z "$prefix" -a -d "/usr/local/freeswitch" ] ; then
|
2009-11-11 22:46:43 -05:00
|
|
|
prefix="/usr/local/freeswitch"
|
2009-10-12 18:22:52 -04:00
|
|
|
fi
|
2010-02-01 10:29:40 -05:00
|
|
|
if [ -z "$prefix" -a -d "/opt/freeswitch" ] ; then
|
|
|
|
prefix="/opt/freeswitch"
|
|
|
|
fi
|
2011-12-19 17:50:02 -05:00
|
|
|
|
|
|
|
if [ -z "$prefix" ] ; then
|
|
|
|
prefix=$FS_PREFIX
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$prefix" -a -f "./bin/freeswitch" ] ; then
|
|
|
|
prefix=`pwd`
|
|
|
|
fi
|
|
|
|
|
2010-02-01 10:29:40 -05:00
|
|
|
if [ -z "$prefix" ] ; then
|
|
|
|
echo "Unable to locate freeswitch prefix directory."
|
|
|
|
exit 255
|
|
|
|
fi
|
2009-10-12 18:22:52 -04:00
|
|
|
|
|
|
|
if [ "$arg" = "gcore" ] ; then
|
|
|
|
user=$1
|
|
|
|
shift
|
2010-01-21 19:31:19 -05:00
|
|
|
fspid=`cat $prefix/run/freeswitch.pid`
|
2009-10-12 18:22:52 -04:00
|
|
|
echo "pulling gcore $fspid"
|
|
|
|
gcore -o core $fspid
|
|
|
|
else
|
|
|
|
user=$arg
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2012-10-10 11:19:40 -04:00
|
|
|
core=`ls -1t core* | head -1 2> /dev/null`
|
2009-09-17 14:48:01 -04:00
|
|
|
|
2009-09-22 19:09:14 -04:00
|
|
|
if [ -z "$core" ] ; then
|
2009-10-12 18:22:52 -04:00
|
|
|
core=`ls -1 core 2> /dev/null`
|
2009-09-22 19:09:14 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$core" ] ; then
|
2009-10-12 18:22:52 -04:00
|
|
|
core=`ls -1 freeswitch.core 2> /dev/null`
|
2009-09-22 19:09:14 -04:00
|
|
|
fi
|
|
|
|
|
2009-09-17 14:48:01 -04:00
|
|
|
if [ -z "$core" ] ; then
|
|
|
|
echo "You must be in the current directory with a core file from FreeSWITCH!"
|
|
|
|
exit 255
|
|
|
|
fi
|
|
|
|
|
2010-02-01 10:29:40 -05:00
|
|
|
if [ -x `which gdb` ] ; then
|
|
|
|
echo "Found gdb"
|
|
|
|
else
|
2009-09-23 11:33:05 -04:00
|
|
|
echo "Unable to locate gdb, is it installed?"
|
|
|
|
exit 255
|
|
|
|
fi
|
|
|
|
|
2009-10-12 18:22:52 -04:00
|
|
|
echo "core is $core"
|
2009-09-23 11:33:05 -04:00
|
|
|
|
2009-09-17 14:48:01 -04:00
|
|
|
line="--------------------------------------------------------------------------------"
|
|
|
|
|
|
|
|
mypwd=`pwd`
|
|
|
|
tmpdir=/tmp/fscore_pb.tmp
|
2009-10-31 14:15:29 -04:00
|
|
|
post_file=$mypwd/fscore_pb.post
|
2009-10-12 18:22:52 -04:00
|
|
|
|
2009-09-17 14:48:01 -04:00
|
|
|
|
|
|
|
if [ -z $user ] ; then
|
|
|
|
user=$SUDO_USER
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z $user ] ; then
|
|
|
|
user=$USER
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z $user ] ; then
|
|
|
|
user="anon"
|
|
|
|
fi
|
|
|
|
|
2014-07-09 10:04:17 -04:00
|
|
|
post_cmd=""
|
|
|
|
command -v wget >/dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
2014-11-12 13:49:57 -05:00
|
|
|
post_cmd="wget --output-file=/dev/null --output-document=/tmp/fscore_pb.tmp/pb_out --http-user=pastebin --http-password=freeswitch https://pastebin.freeswitch.org --post-file=$post_file"
|
|
|
|
echo -n "paste=Send&remember=0&poster=$user&format=none&expiry=f&code2=" > $post_file
|
2014-07-09 10:04:17 -04:00
|
|
|
fi
|
2009-09-17 14:48:01 -04:00
|
|
|
|
2014-07-09 10:04:17 -04:00
|
|
|
if [ -z "$post_cmd" ]; then
|
|
|
|
command -v curl >/dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
post_cmd="curl -o /tmp/fscore_pb.tmp/pb_out --user pastebin:freeswitch http://pastebin.freeswitch.org -d paste=Send -d remember=0 -d poster=$user -d format=none -d expiry=f --data-urlencode code2@$post_file"
|
|
|
|
fi
|
|
|
|
fi
|
2009-09-17 14:48:01 -04:00
|
|
|
|
2014-07-09 10:04:17 -04:00
|
|
|
if [ -z "$post_cmd" ]; then
|
|
|
|
echo "Unable to locate wget or curl."
|
|
|
|
exit 255
|
|
|
|
fi
|
2009-09-17 14:48:01 -04:00
|
|
|
|
2014-07-09 10:04:17 -04:00
|
|
|
echo "Gathering Data Please Wait........."
|
|
|
|
|
2014-11-12 13:49:57 -05:00
|
|
|
UNAME=`uname`;
|
|
|
|
|
2014-07-09 10:04:17 -04:00
|
|
|
#Linux
|
2014-11-12 13:49:57 -05:00
|
|
|
if [ "${UNAME}" = "Linux" ]; then
|
2014-07-09 10:04:17 -04:00
|
|
|
echo "LSB RELEASE:" >> $post_file
|
|
|
|
echo $line >> $post_file
|
2014-11-12 13:49:57 -05:00
|
|
|
if [ -f /etc/redhat-release ]; then
|
2014-07-09 10:04:17 -04:00
|
|
|
cat /etc/redhat-release >> $post_file
|
|
|
|
else
|
|
|
|
lsb_release -a >> $post_file
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "CPU INFO:" >> $post_file
|
|
|
|
echo $line >> $post_file
|
|
|
|
cat /proc/cpuinfo >> $post_file
|
|
|
|
#Mac
|
2014-11-12 13:49:57 -05:00
|
|
|
elif [ "${UNAME}" = "Darwin" ]; then
|
2014-07-09 10:04:17 -04:00
|
|
|
system_profiler SPSoftwareDataType SPHardwareDataType >> $post_file
|
|
|
|
fi;
|
2009-09-17 14:48:01 -04:00
|
|
|
|
2011-03-17 15:18:08 -04:00
|
|
|
echo "GIT INFO:" >> $post_file
|
2009-09-17 14:48:01 -04:00
|
|
|
echo $line >> $post_file
|
|
|
|
echo -n "Revision: " >> $post_file
|
2011-03-17 15:18:08 -04:00
|
|
|
if [ -d ".git" ] ; then
|
|
|
|
git log -1 | cat >> $post_file
|
|
|
|
printf "\n\n\n" >> $post_file
|
|
|
|
git status >> $post_file
|
2010-02-01 10:29:40 -05:00
|
|
|
else
|
2011-03-17 15:18:08 -04:00
|
|
|
echo "Not run from an git managed directory." >> $post_file
|
2010-02-01 10:29:40 -05:00
|
|
|
fi
|
2009-09-17 14:48:01 -04:00
|
|
|
|
|
|
|
echo "GDB BACKTRACE:" >> $post_file
|
|
|
|
echo $line >> $post_file
|
|
|
|
|
2014-07-09 10:04:17 -04:00
|
|
|
cat > fscore_pb.$$.gdb <<EOF
|
|
|
|
echo \n\n
|
|
|
|
set pagination off
|
|
|
|
echo Thread Info\n
|
|
|
|
echo $line\n
|
|
|
|
info threads
|
|
|
|
echo Stack Trace\n
|
|
|
|
echo $line
|
|
|
|
bt
|
|
|
|
echo \n\n\n\n Stack Trace (full)\n
|
|
|
|
echo $line\n
|
|
|
|
bt full
|
|
|
|
echo \n\n\n\n Stack Trace (all threads)\n
|
|
|
|
echo $line\n
|
|
|
|
thread apply all bt
|
|
|
|
echo \n\n\n\n Stack Trace (all threads) (full)\n
|
|
|
|
echo $line\n
|
|
|
|
thread apply all bt full
|
|
|
|
quit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
gdb $prefix/bin/freeswitch `echo $core | tail -n1` -x fscore_pb.$$.gdb 1 >> $post_file 2>/dev/null
|
|
|
|
|
|
|
|
rm fscore_pb.$$.gdb
|
2009-09-17 14:48:01 -04:00
|
|
|
rm -fr $tmpdir
|
|
|
|
mkdir -p $tmpdir
|
|
|
|
cd $tmpdir
|
|
|
|
|
2014-07-09 10:04:17 -04:00
|
|
|
echo $post_cmd
|
|
|
|
$post_cmd
|
2009-09-17 14:48:01 -04:00
|
|
|
|
2009-09-18 11:42:54 -04:00
|
|
|
mv $post_file $tmpdir
|
2014-07-09 10:04:17 -04:00
|
|
|
|
2009-09-17 14:48:01 -04:00
|
|
|
echo "Finished."
|
2014-07-09 10:04:17 -04:00
|
|
|
if [ -e /tmp/fscore_pb.tmp/pb_out ]; then
|
|
|
|
pb=`cat /tmp/fscore_pb.tmp/pb_out | grep parent_pid | awk -F \" '{print $6}'`
|
|
|
|
echo "Please report http://pastebin.freeswitch.org/$pb to the developers."
|
|
|
|
else
|
|
|
|
echo "Please check recent posts on http://pastebin.freeswitch.org/ and find your issue to report to the developers."
|
|
|
|
fi
|