diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2006-04-19 20:48:22 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2006-04-19 20:48:22 +0000 |
commit | d35e785f58e5c1f8381c5a7ce289ba3d3aa0de03 (patch) | |
tree | 5e8245b797dd528e1e4305379d1f11214e9eff93 /packages | |
parent | d800eb45d58bc1ff7c22c3ecbd78d285232602c9 (diff) | |
download | pfsense-packages-d35e785f58e5c1f8381c5a7ce289ba3d3aa0de03.tar.gz pfsense-packages-d35e785f58e5c1f8381c5a7ce289ba3d3aa0de03.tar.bz2 pfsense-packages-d35e785f58e5c1f8381c5a7ce289ba3d3aa0de03.zip |
Cleanup UPNP package and use <include_file>
Diffstat (limited to 'packages')
-rw-r--r-- | packages/upnpd.inc | 38 | ||||
-rw-r--r-- | packages/upnpd.xml | 43 |
2 files changed, 47 insertions, 34 deletions
diff --git a/packages/upnpd.inc b/packages/upnpd.inc new file mode 100644 index 00000000..e4960439 --- /dev/null +++ b/packages/upnpd.inc @@ -0,0 +1,38 @@ +<?php + function sync_upnp() { + global $config, $g; + $lanif = $config['interfaces']['lan']['if']; + $wanif = get_real_wan_interface(); + $lanip = find_interface_ip($lanif); + /* copy original, we're going to overwrite ADDR with our internal ip */ + copy("/usr/local/etc/linuxigd/gatedesc.xml.bak", "/usr/local/etc/linuxigd/gatedesc.xml"); + /* replace ADDR with LAN ip */ + $file_contents = file_get_contents("/usr/local/etc/linuxigd/gatedesc.xml"); + $file_contents = str_replace("!ADDR!","{$lanip}",$file_contents); + $fout = fopen("/usr/local/etc/linuxigd/gatedesc.xml", "w"); + fwrite($fout, $file_contents); + fclose($fout); + /* write out custom rc.d starter script */ + $fout = fopen("/usr/local/etc/rc.d/upnpd.sh", "w"); + fwrite($fout, "#!/bin/sh\n# This package was automatically generated\n# by the pfSense package system.\n\n"); + fwrite($fout, "# PACKAGE: UPNP\n"); + fwrite($fout, "# EXECUTABLE: upnpd\n\n"); + fwrite($fout, "/usr/local/bin/upnpd {$wanif} {$lanif}"); + fclose($fout); + chmod("/usr/local/etc/rc.d/upnpd.sh", 0755); + /* kill it off if its running */ + mwexec("killall upnpd"); + /* alright, thats all we need. start up! */ + mwexec("/usr/local/etc/rc.d/upnpd.sh"); + } + function upnp_install() { + /* we need to update the files ADDR from time to time which is the lan ip */ + copy("/usr/local/etc/linuxigd/gatedesc.xml", "/usr/local/etc/linuxigd/gatedesc.xml.bak"); + unlink("/usr/local/etc/rc.d/linuxigd.sh.sample"); + } + function upnp_deinstall() { + mwexec("rm -rf /usr/local/etc/rc.d/upnpd.sh"); + mwexec("rm -rf /usr/local/etc/linuxigd"); + } +?> +
\ No newline at end of file diff --git a/packages/upnpd.xml b/packages/upnpd.xml index 69bebe82..e15d7cfd 100644 --- a/packages/upnpd.xml +++ b/packages/upnpd.xml @@ -2,44 +2,19 @@ <packagegui> <name>upnp</name> <version>0.92_2</version> - <custom_php_command_before_form> - </custom_php_command_before_form> + <additional_files_needed> + <prefix>/usr/local/pkg/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/upnpd.inc</item> + </additional_files_needed> <custom_php_resync_config_command> - function sync_upnp() { - global $config, $g; - $lanif = $config['interfaces']['lan']['if']; - $wanif = get_real_wan_interface(); - $lanip = find_interface_ip($lanif); - /* copy original, we're going to overwrite ADDR with our internal ip */ - copy("/usr/local/etc/linuxigd/gatedesc.xml.bak", "/usr/local/etc/linuxigd/gatedesc.xml"); - /* replace ADDR with LAN ip */ - $file_contents = file_get_contents("/usr/local/etc/linuxigd/gatedesc.xml"); - $file_contents = str_replace("!ADDR!","{$lanip}",$file_contents); - $fout = fopen("/usr/local/etc/linuxigd/gatedesc.xml", "w"); - fwrite($fout, $file_contents); - fclose($fout); - /* write out custom rc.d starter script */ - $fout = fopen("/usr/local/etc/rc.d/upnpd.sh", "w"); - fwrite($fout, "#!/bin/sh\n# This package was automatically generated\n# by the pfSense package system.\n\n"); - fwrite($fout, "# PACKAGE: UPNP\n"); - fwrite($fout, "# EXECUTABLE: upnpd\n\n"); - fwrite($fout, "/usr/local/bin/upnpd {$wanif} {$lanif}"); - fclose($fout); - chmod("/usr/local/etc/rc.d/upnpd.sh", 0755); - /* kill it off if its running */ - mwexec("killall upnpd"); - /* alright, thats all we need. start up! */ - mwexec("/usr/local/etc/rc.d/upnpd.sh"); - } - sync_upnp(); + sync_upnp(); </custom_php_resync_config_command> <custom_php_install_command> - /* we need to update the files ADDR from time to time which is the lan ip */ - copy("/usr/local/etc/linuxigd/gatedesc.xml", "/usr/local/etc/linuxigd/gatedesc.xml.bak"); - unlink("/usr/local/etc/rc.d/linuxigd.sh.sample"); + upnp_install(); </custom_php_install_command> <custom_php_deinstall_command> - mwexec("rm -rf /usr/local/etc/rc.d/upnpd.sh"); - mwexec("rm -rf /usr/local/etc/linuxigd"); + upnp_deinstall(); </custom_php_deinstall_command> + <include_file>/usr/local/pkg/upnpd.inc</include_file> </packagegui> |