Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
mldonkey bash script for adding iptables chain not working
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
svenc
n00b
n00b


Joined: 06 Apr 2003
Posts: 33

PostPosted: Mon Feb 28, 2011 3:21 am    Post subject: mldonkey bash script for adding iptables chain not working Reply with quote

Found this script on http://mldonkey.sourceforge.net/WhatFirewallPortsToOpen

Line beginning with egrep doesn't work, but I don't understand bash well enough to see why. Anybody ?
Code:
#!/sbin/runscript

depend() {
    need mldonkey
}

start() {
    UDP_PORTS=$(lsof -i -n | grep mlnet | grep -v -- '-' | grep UDP | cut -d ':' -f 2)
    lsof -i -n | grep mlnet | grep -v -- '-' | grep TCP | cut -d ':' -f 2 | cut -d ' ' -f 1 | sort > /tmp/ml_tcp_ports
    egrep \"^\ '''.'''_port\ *=\ '''[[ egrep -o \"[0-9|0-9]]'''$\" /home/p2p/mldonkey/downloads.ini |]+\" | sort > /tmp/ml_ui_ports
    TCP_PORTS=$(comm -2 -3 /tmp/ml_tcp_ports /tmp/ml_ui_ports)
    rm /tmp/ml_tcp_ports
    rm /tmp/ml_ui_ports

    ebegin \"Preparing mldonkey chain\"
    iptables -F mldonkey > /dev/null 2>&1 || iptables -N mldonkey > /dev/null 2>&1
    eend $?

    for port in $UDP_PORTS; do
        ebegin \"Adding UDP:$port to ACCEPT list\"
        iptables -A mldonkey -p udp --dport $port -j ACCEPT
        eend $?
    done

    for port in $TCP_PORTS; do
        ebegin \"Adding TCP:$port to ACCEPT list\"
        iptables -A mldonkey -p tcp --dport $port -j ACCEPT
        eend $?
    done
}

stop () {
    ebegin \"Flushing mldonkey chain\"
    iptables -F mldonkey
    eend $?
}
Back to top
View user's profile Send private message
Bones McCracker
Veteran
Veteran


Joined: 14 Mar 2006
Posts: 1609
Location: U.S.A.

PostPosted: Sun Mar 20, 2011 8:59 am    Post subject: Reply with quote

If you still need an answer, start by including the output of the script (i.e., just saying "it doesn't work" is not particularly useful and is probably why you got no responses).
_________________
patrix_neo wrote:
The human thought: I cannot win.
The ratbrain in me : I can only go forward and that's it.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum