--- Portfile.org	2007-11-02 18:19:03.000000000 -0700
+++ Portfile	2007-11-03 14:47:12.000000000 -0700
@@ -1,8 +1,9 @@
 # $Id: Portfile 30551 2007-10-31 05:02:34Z ryandesign@macports.org $
 
 PortSystem 1.0
+
 name		tftp-hpa
-version		0.40
+version		0.48
 categories	net
 maintainers	digdog@macports.org
 description	Enhanced port of the BSD TFTP server
@@ -15,7 +16,22 @@
 homepage	http://www.kernel.org/pub/software/network/tftp/
 master_sites	${homepage}
 use_bzip2	yes
-checksums	md5 bfcdd49bf94900e610f2cc937d8980ef
+checksums	md5 f2e0a1ca0c49ae46ecad26a54df3e887
+
+set tftp-root	${prefix}/var/${name}/
+
+variant enable_upload description { If invoked with the server variant, tftp uploads
+	are enabled; without the server variant, this variant has no effect } {}
+
+variant server description { Install launchd scripts to run tftpd at system boot } {
+	startupitem.create	yes
+	startupitem.name	tftpd
+		if { ! [variant_isset enable_upload] } {
+			startupitem.executable	${prefix}/sbin/tftpd -L -s ${tftp-root}
+		} else {
+			startupitem.executable  ${prefix}/sbin/tftpd -L -c -s ${tftp-root}
+		}
+}
 
 configure.args	--mandir=\\\${prefix}/share/man
 
@@ -28,21 +44,42 @@
 	file delete ${destroot}${prefix}/share/man/man8/tftpd.8
 	file rename ${destroot}${prefix}/share/man/man8/in.tftpd.8 \
 		${destroot}${prefix}/share/man/man8/tftpd.8
+
+	reinplace "s|in.tftpd|tftpd|g" \
+		${destroot}${prefix}/share/man/man8/tftpd.8
+
+	xinstall -m 777 -d ${tftp-root}
+	destroot.keepdirs ${tftp-root}
 }
 
-# Tell the user that the server needs to be used through (x)inetd/launchd
+# tftp-ha setup instructions
 post-install {
-        ui_msg "\nTo use tftpd, you'll need to modify settings in inetd.conf/xinetd.d/launchd"
-        ui_msg "depending on what you use on your system.\n\n"
-        ui_msg "For inetd, something like:"
-        ui_msg "tftp  dgram   udp  wait    nobody  ${prefix}/sbin/in.tftd  tftpd /private/tftpboot"
-        ui_msg "should do it. And tell inetd to reload its configuration.\n\n"
-        ui_msg "For xinetd (the default on Mac OS X 10.3), you should edit the file /etc/xinetd.d/tftp\n"
-        ui_msg "and change the server setting from /usr/libexec/tftpd to ${prefix}/sbin/in.tftd\n"
-        ui_msg "Then, use service(8) command to reload the xinetd configuration.\n\n"
-        ui_msg "For launchd (the default on Mac OS X 10.4 Tiger), you'll need to change the \n"
-        ui_msg "tftp.plist file in /System/Library/LaunchDaemons/. By changing the first string\n"
-        ui_msg "value inside the ProgramArguments key from /usr/libexec/tftpd to ${prefix}/sbin/in.tftd\n"
-        ui_msg "And start the server with the service(8) command.\n"
+	ui_msg "\n
+
+***** Setup Instructions *****
+
+To run tftpd manually for download only access, use this command:
+	sudo ${prefix}/sbin/tftpd -L -s <tftp-root-dir>
+
+To run tftpd manually and support tftp uploads, add \"-c\" to the command:
+	sudo ${prefix}/sbin/tftpd -L -c -s <tftp-root-dir>
+
+You may run tftpd at system boot on OS X 10.4 or 10.5 if you installed tftp-hpa
+using the server variant; if so, you may load it using launchctl:
+	sudo launchctl load -w /Library/LaunchDaemons/org.macports.tftpd.plist
+
+By default, tftp-hpa listens to the tftp port specified in /etc/services (port 69)
+on all local addresses.
+
+NOTE: When loading tftp-hpa using launchctl, make sure to place the files you want to serve
+in ${tftp-root}, because that is the location set by the StartupItem.
+
+*******************************
+
+If you wish to run tftpd in inetd mode, you may make an inetd compatible .plist
+file and replace the one installed by MacPorts in /Library/LaunchDaemons.  You
+may use /System/Library/LaunchDaemons/tftp.plist as a template.
+
+\n"
 }
 

