mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Add check UPNP
This commit is contained in:
parent
f5f3e7d341
commit
2f2d1c84b1
3 changed files with 45 additions and 2 deletions
|
@ -504,6 +504,11 @@ firewall:
|
||||||
### firewall_stop()
|
### firewall_stop()
|
||||||
stop:
|
stop:
|
||||||
action_help: Stop iptables and ip6tables
|
action_help: Stop iptables and ip6tables
|
||||||
|
|
||||||
|
|
||||||
|
### firewalli_checkUPNP()
|
||||||
|
checkUPNP:
|
||||||
|
action_help: check if UPNP is install or not (0 yes 1 no)
|
||||||
#############################
|
#############################
|
||||||
# Tools #
|
# Tools #
|
||||||
#############################
|
#############################
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
UPNP: false
|
||||||
ipv4:
|
ipv4:
|
||||||
TCP: [22, 25, 53, 80, 443, 5222, 5269, 5280, 6767]
|
TCP: [22, 25, 53, 80, 443, 5222, 5269, 5280, 6767]
|
||||||
UDP: [53]
|
UDP: [53]
|
||||||
|
|
|
@ -227,10 +227,21 @@ def firewall_installupnp():
|
||||||
Return
|
Return
|
||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
with open('firewall.yml', 'r') as f:
|
||||||
|
firewall = yaml.load(f)
|
||||||
|
|
||||||
|
firewall['UPNP']=True;
|
||||||
|
|
||||||
os.system("touch /etc/cron.d/yunohost-firewall")
|
os.system("touch /etc/cron.d/yunohost-firewall")
|
||||||
os.system("echo '*/50 * * * * root yunohost firewall reload -u>>/dev/null'>/etc/cron.d/yunohost-firewall")
|
os.system("echo '*/50 * * * * root yunohost firewall reload -u>>/dev/null'>/etc/cron.d/yunohost-firewall")
|
||||||
win_msg(_("UPNP cron installed"))
|
win_msg(_("UPNP cron installed"))
|
||||||
|
|
||||||
|
os.system("mv firewall.yml firewall.yml.old")
|
||||||
|
|
||||||
|
with open('firewall.yml', 'w') as f:
|
||||||
|
yaml.dump(firewall, f)
|
||||||
|
|
||||||
|
|
||||||
def firewall_removeupnp():
|
def firewall_removeupnp():
|
||||||
"""
|
"""
|
||||||
|
@ -240,14 +251,39 @@ def firewall_removeupnp():
|
||||||
Return
|
Return
|
||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
|
with open('firewall.yml', 'r') as f:
|
||||||
|
firewall = yaml.load(f)
|
||||||
|
|
||||||
|
firewall['UPNP']=False;
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.remove("/etc/cron.d/yunohost-firewall")
|
os.remove("/etc/cron.d/yunohost-firewall")
|
||||||
except:
|
except:
|
||||||
raise YunoHostError(167,_("UPNP cron was not installed!"))
|
raise YunoHostError(167,_("UPNP cron was not installed!"))
|
||||||
|
|
||||||
win_msg(_("UPNP cron removed"))
|
win_msg(_("UPNP cron removed"))
|
||||||
|
|
||||||
|
os.system("mv firewall.yml firewall.yml.old")
|
||||||
|
|
||||||
|
with open('firewall.yml', 'w') as f:
|
||||||
|
yaml.dump(firewall, f)
|
||||||
|
|
||||||
|
def firewall_checkUPNP():
|
||||||
|
"""
|
||||||
|
Check if UPNP is installed
|
||||||
|
Keyword arguments:
|
||||||
|
None
|
||||||
|
Return
|
||||||
|
0 if installed
|
||||||
|
1 if not
|
||||||
|
"""
|
||||||
|
with open('firewall.yml', 'r') as f:
|
||||||
|
firewall = yaml.load(f)
|
||||||
|
|
||||||
|
if firewall['UPNP']:
|
||||||
|
win_msg(_("UPNP is activated"))
|
||||||
|
else:
|
||||||
|
raise YunoHostError(167,_("UPNP not activated!"))
|
||||||
|
|
||||||
def firewall_stop():
|
def firewall_stop():
|
||||||
"""
|
"""
|
||||||
|
@ -265,5 +301,6 @@ def firewall_stop():
|
||||||
os.system ("ip6tables -P INPUT ACCEPT")
|
os.system ("ip6tables -P INPUT ACCEPT")
|
||||||
os.system ("ip6tables -F")
|
os.system ("ip6tables -F")
|
||||||
os.system ("ip6tables -X")
|
os.system ("ip6tables -X")
|
||||||
|
if(os.path.exists("/etc/cron.d/yunohost-firewall")):
|
||||||
|
firewall_removeupnp()
|
||||||
|
|
||||||
firewall_removeupnp()
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue