mirror of https://github.com/pissnet/pissircd
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
177 lines
5.4 KiB
Bash
177 lines
5.4 KiB
Bash
#!/bin/sh
|
|
|
|
PID_FILE="@PIDFILE@"
|
|
PID_BACKUP="@PIDFILE@.bak"
|
|
if [ ! -f @BINDIR@/unrealircd ]; then
|
|
echo "ERROR: Could not find the IRCd binary (@BINDIR@/unrealircd)"
|
|
echo "This could mean two things:"
|
|
echo "1) You forgot to run 'make install' after running 'make'"
|
|
echo "2) You answered a ./Config question incorrectly"
|
|
exit
|
|
fi
|
|
if [ "$1" = "start" ] ; then
|
|
echo "Starting UnrealIRCd"
|
|
if [ -r $PID_FILE ] ; then
|
|
mv -f $PID_FILE $PID_BACKUP
|
|
fi
|
|
# Check if ~/Unreal3.4.x/unrealircd.conf exists but the file
|
|
# ~/unrealircd/conf/unrealircd.conf does not.
|
|
# If so, then assume a user-build and give the user a nice hint...
|
|
if [ ! -f @CONFDIR@/unrealircd.conf -a -f @BUILDDIR@/unrealircd.conf ]; then
|
|
echo ""
|
|
echo "There is no unrealircd.conf in @CONFDIR@"
|
|
echo "However I did find an unrealircd.conf in @BUILDDIR@"
|
|
echo "With UnrealIRCd 3.4.x you should no longer run the IRCd from @BUILDDIR@."
|
|
echo "You should 'cd @SCRIPTDIR@' and work from there."
|
|
echo "See https://www.unrealircd.org/docs/UnrealIRCd_files_and_directories"
|
|
exit 1
|
|
fi
|
|
@BINDIR@/unrealircd
|
|
sleep 1
|
|
if [ ! -r $PID_FILE ] ; then
|
|
echo "Possible error encountered (IRCd seemingly not started)"
|
|
echo "====================================================="
|
|
echo "Check above for possible errors and the output below of @LOGDIR@/ircd.log"
|
|
echo "If you don't understand the problem, then have a look at our:"
|
|
echo "* FAQ: https://www.unrealircd.org/faq (Frequently Asked Questions)"
|
|
echo "* Documentation: https://www.unrealircd.org/docs/"
|
|
echo "====================================================="
|
|
tail -n 5 @LOGDIR@/ircd.log
|
|
if [ -r $PID_BACKUP ] ; then
|
|
mv -f $PID_BACKUP $PID_FILE
|
|
fi
|
|
fi
|
|
elif [ "$1" = "stop" ] ; then
|
|
echo "Stopping UnrealIRCd"
|
|
if [ ! -r $PID_FILE ] ; then
|
|
echo "ERROR: UnrealIRCd is not running"
|
|
exit 1
|
|
fi
|
|
kill -15 `cat $PID_FILE`
|
|
if [ "$?" != 0 ]; then
|
|
echo "ERROR: UnrealIRCd is not running"
|
|
exit 1
|
|
fi
|
|
sleep 1
|
|
kill -9 `cat $PID_FILE` 1>/dev/null 2>&1
|
|
elif [ "$1" = "rehash" ] ; then
|
|
echo "Rehashing UnrealIRCd"
|
|
if [ ! -r $PID_FILE ] ; then
|
|
echo "ERROR: UnrealIRCd is not running"
|
|
exit 1
|
|
fi
|
|
kill -1 `cat $PID_FILE`
|
|
if [ "$?" != 0 ]; then
|
|
echo "ERROR: UnrealIRCd is not running"
|
|
exit 1
|
|
fi
|
|
elif [ "$1" = "restart" ] ; then
|
|
echo "Restarting UnrealIRCd"
|
|
if [ ! -r $PID_FILE ] ; then
|
|
echo "WARNING: UnrealIRCd was not running"
|
|
else
|
|
kill -15 `cat $PID_FILE`
|
|
if [ "$?" != 0 ]; then
|
|
echo "WARNING: UnrealIRCd was not running"
|
|
else
|
|
sleep 1
|
|
kill -9 `cat $PID_FILE` 1>/dev/null 2>&1
|
|
fi
|
|
fi
|
|
$0 start
|
|
elif [ "$1" = "mkpasswd" ] ; then
|
|
@BINDIR@/unrealircd -P $2 $3
|
|
elif [ "$1" = "version" ] ; then
|
|
@BINDIR@/unrealircd -v
|
|
elif [ "$1" = "gencloak" ] ; then
|
|
@BINDIR@/unrealircd -k
|
|
elif [ "$1" = "upgrade-conf" ] ; then
|
|
@BINDIR@/unrealircd -U
|
|
elif [ "$1" = "backtrace" ] ; then
|
|
cd @IRCDDIR@
|
|
|
|
modpath="@MODULESDIR@"
|
|
|
|
# Find the corefile
|
|
echo "Core files available:"
|
|
n="0"
|
|
for i in `echo *core*`
|
|
do
|
|
ls -l $i
|
|
n=`expr $n + 1`
|
|
done
|
|
|
|
if [ "$n" -gt 1 ]; then
|
|
echo "Type the name of the core file you want to research:"
|
|
read corefile
|
|
elif [ "$i" = "*core*" -o "$n" -eq 0 ]; then
|
|
echo 'No core files found... Nothing to do'
|
|
echo ''
|
|
echo 'If you are sure UnrealIRCd crashed, then verify that unreal'
|
|
echo 'has permission to dump core (type "ulimit -c unlimited" and see'
|
|
echo 'if you get permission denied errors). Also verify that you did'
|
|
echo 'not run out of quota.'
|
|
echo 'If all that is ok, then it might be that Unreal did not crash but'
|
|
echo 'got killed by the OS (eg: cpu/mem resource limits), the syadmin,'
|
|
echo 'or an automated process.'
|
|
exit 1
|
|
else
|
|
corefile="$i"
|
|
fi
|
|
|
|
if [ ! -f "$corefile" ]; then
|
|
echo "Core file '$corefile' not found"
|
|
fi
|
|
if [ ! -s "$corefile" ]; then
|
|
echo 'Seems the corefile is 0 bytes'
|
|
echo 'This usually means you need to relax the core file resource limit'
|
|
echo '(type "ulimit -c unlimited"), or you might have ran out of quota.'
|
|
exit 1
|
|
fi
|
|
|
|
# The tmp/*.so files are often already deleted. Here we have some
|
|
# (ugly) scripting to recreate the tmp/*.so links to the modules *.so files...
|
|
echo 'info sharedlibrary'|gdb @BINDIR@/unrealircd $corefile 2>/dev/null|\
|
|
grep No|grep tmp/|awk '{ print $2 }'|\
|
|
awk -F '.' "{ system(\"ln -s ../$modpath/\" \$2 \".so \" \$0) }"
|
|
|
|
echo ""
|
|
echo "=================== START HERE ======================"
|
|
echo "BACKTRACE:"
|
|
|
|
cat >gdb.commands << __EOF__
|
|
bt
|
|
echo \n
|
|
frame
|
|
echo \n
|
|
x/s backupbuf
|
|
echo \n
|
|
bt 3 full
|
|
quit
|
|
__EOF__
|
|
|
|
gdb -batch -x gdb.commands @BINDIR@/unrealircd $corefile
|
|
rm -f gdb.commands
|
|
echo "GCC: `gcc -v 2>&1|tail -n 1`"
|
|
echo "UNAME: `uname -a`"
|
|
echo "UNREAL: `$0 version`"
|
|
echo "CORE: `ls -al $corefile`"
|
|
echo "=================== STOP HERE ======================"
|
|
echo ""
|
|
echo "Copy the parts between the START HERE and STOP HERE marker"
|
|
echo "and report it on http://bugs.unrealircd.org/"
|
|
echo ""
|
|
echo 'But before you do, note the following:'
|
|
echo '1. We do not support modifications of any unrealircd code'
|
|
echo ' (except for config.h changes).'
|
|
echo '2. If you are using 3rd party modules we might request you'
|
|
echo ' to run without them and verify you still crash. This is'
|
|
echo ' to eleminate any loss of time due to bugs made by others'
|
|
echo '3. Always use the latest UnrealIRCd version, we fix (crash)bugs'
|
|
echo ' all the time so your bug might as well be fixed already.'
|
|
echo ""
|
|
echo "Thanks!"
|
|
else
|
|
echo "Usage: unreal start|stop|rehash|restart|mkpasswd|version|gencloak|upgrade-conf"
|
|
fi
|