Background
in the same vain as how ndt uses fakewww, the implementation of the reverse traceroute server uses a daemon called shttpd. This page shows how to make the reverse traceroute server use apache instead.
Virtual Server
We construct the virtual server config:
Code Block |
---|
title | /etc/apache2/sites-enabled/002-revtr |
---|
|
NameVirtualHost *:3765
<VirtualHost *:3765>
ServerAdmin webmaster@localhost
DocumentRoot /usr/local/rev-tr
<Directory /usr/local/rev-tr>
AllowOverride None
Options +ExecCGI
AddHandler cgi-script .pl
</Directory>
AddHandler cgi-script .pl
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
|
Don't forget the port
Code Block |
---|
title | /etc/apache2/ports.conf |
---|
|
Listen 3765
|
Disable shttpd
To do this, edit the init.d file.
Configuration Files
knoppix.sh
Code Block |
---|
# use apache for the rev traceroute server
if [ -f /UNIONFS/media/$MNT/NPTools/002\-revtr ]; then
# setup the init.d script
restore_NPT_file $MNT rev\-tr /etc/init.d
# setup the apache conf
restore_NPT_file $MNT 002\-revtr /etc/apache2/sites-enabled
fi
|
rev-tr init.d script
Code Block |
---|
#!/bin/bash
#
# chkconfig: 2345 55 25
# description: Starts the NDT Web server
# written by Peter Bertoncini <pjb@anl.gov>
#
# Customized NTP startup script for Internet Network Performance Tools
# Live CD. The process for this tool, and all the others, it to let
# Knoppix take care of some customization during the boot phase. Knoppix
# will automatically look for, and execute, a knoppix.sh script on an
# attached drive. This means that we will store the customized file
# on a USB thumb drive. At boot time the boot process will find and
# execute a knoppix.sh script that will copy the config files into
# the proper place. If they don't exist, then prompt the user to
# customize things.
#
# At shutdown, copy the files back to the mounted USB drive.
# Rich Carlson - 4/20/06
path=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
# set to 0 to not run the http server; assume something like apache will run it
REVTR=0
# bring in NPT functions for later use
ENV="env -i PATH=/lib/init:/bin:/sbin:/usr/bin"
. /lib/init/nptoolkit-functions.sh
if [ ! $REVTR ] ; then
[ -f $REVTR ] || exit 0
fi
# Specify some default options.
REVTR_OPTIONS="-p3765 -d /usr/local/rev-tr -c .pl -C/usr/bin/perl"
case "$1" in
start)
echo -n "Starting Reverse Traceroute Services: "
if [ -f /usr/local/rev-tr/traceroute.pl ]; then
echo " - using customized reverse traceroute web server."
else
/bin/cp /usr/local/etc/rev-tr.knoppix /usr/local/rev-tr/traceroute.pl
echo " - using generic rev-tr web server page"
/bin/touch /tmp/customize.rev-tr
fi
mkdir -p /var/run/rev-tr/run
chmod 755 /var/run/rev-tr/run
chown root:wheel /var/run/rev-tr/run >/dev/null 2>&1 || true
if [ ! -x $REVTR ]; then
echo "Reverse Traceroute web server binary missing - Not starting"
exit 1
fi
if [ ! $REVTR ]; then
start-stop-daemon --start -m --pidfile=/var/run/rev-tr/run/rev-tr.pid \
--exec $REVTR -- $REVTR_OPTIONS >/dev/null 2>&1 &
fi
echo "Reverse-Traceroute: "
;;
stop)
echo -n "Stopping Rev-TR services: "
if [ ! $REVTR ]; then
start-stop-daemon --stop --name rev-tr
fi
echo -n "rev-tr"
mount_NPT_drives
select_NPT_drive
if [ "$DRVS" == "" ] ; then
echo "Error: No drive avaialble to hold traceroute/ping server customization files."
else
for DRV in $DRVS ; do
save_NPT_file $DRV /usr/local/rev-tr/traceroute.pl traceroute.pl
echo "Saving Traceroute/Ping server customizatin files on '$DRV' drive."
done
fi
echo "."
;;
restart)
echo -n "Restarting Reverse Traceroute services: "
if [ ! $REVTR ]; then
start-stop-daemon --stop --name rev-tr
sleep 2
start-stop-daemon --start -m --pidfile=/var/run/rev-tr/run/rev-tr.pid \
--exec $REVTR -- $REVTR_OPTIONS >/dev/null 2>&1 &
fi
echo -n "Reverse-traceroute"
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0
|
Problems
The version of traceroute.pl supplied on the disk does not have executable flags set. I added chmod to the knoppix.sh for the file, however, it doesn't appear to work during boot (running the same command on login is fine however).