Hi, On 14 December 2010 12:35, Bogdan Giuglea <[email protected]> wrote: > This changes miniupnpd init so user can enable/disable nat-pmp and upnp > functions via /etc/config/upnpd by adding "option 'natpmp' '1'" and "option > 'upnp' '1'" > upnp function is enabled by default > > Signed-off-by: Bogdan <[email protected]> > > --- openwrt/packages/net/miniupnpd/files/miniupnpd.initSat Nov 20 05:36:46 > 2010 > +++ openwrt/packages/net/miniupnpd/files/miniupnpd.initTue Dec 14 12:42:16 > 2010 > @@ -15,6 +15,8 @@ > config_get_bool logging config log_output 0 > config_get_bool secure config secure_mode 0 > config_get_bool enabled config enabled 0 > +config_get_bool natpmp config natpmp 0 > +config_get_bool upnp config upnp 1 > > include /lib/network > scan_interfaces > @@ -22,6 +24,8 @@ > local ifname > config_get ifname ${extiface:-wan} ifname > > +rm /etc/miniupnpd.conf > +
Please avoid (real) file modifications in an init script. If miniupnpd needs its config there, create a symlink to a file in /tmp that you create based on the /etc/config/upnpd. See Samba3's init script for an example (<https://dev.openwrt.org/browser/packages/net/samba3/files/samba.init#L25>). > if [ -n "$ifname" ]; then > local args="-i $ifname" > local iface > @@ -32,7 +36,20 @@ > [ -n "$ipaddr" ] && append args "-a $ipaddr" > done > > -append args "-p 5000 -U" > +if [ "$upnp" = "1" ]; then > +append args "-p 5000" > +echo enable_upnp=yes >> /etc/miniupnpd.conf & > +else > +echo enable_upnp=no >> /etc/miniupnpd.conf & > +fi > + > +if [ "$natpmp" = "1" ]; then > +echo enable_natpmp=yes >> /etc/miniupnpd.conf & > +else > +echo enable_natpmp=no >> /etc/miniupnpd.conf & > +fi See above. Also, wouldn't this create a race condition between both echo's? > + > +append args "-U" > > [ -n "$upload" -a -n "$download" ] && \ > append args "-B $(($download * 1024 * 8)) $(($upload * 1024 * 8))" > > > > _______________________________________________ > openwrt-devel mailing list > [email protected] > https://lists.openwrt.org/mailman/listinfo/openwrt-devel > _______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/mailman/listinfo/openwrt-devel
