mirror of
https://gitlab.crans.org/mediatek/med.git
synced 2024-12-25 05:42:24 +00:00
Commandes de management
This commit is contained in:
parent
353cea2fe2
commit
0db6c091aa
@ -11,11 +11,11 @@ User=root
|
||||
Group=root
|
||||
PIDFile=/run/portail_captif.pid
|
||||
WorkingDirectory=/var/www/portail_captif/
|
||||
ExecStartPre=/usr/bin/python3 /var/www/portail_captif/portail_captif/start_portail.py
|
||||
ExecStartPre=/usr/bin/python3 /var/www/portail_captif/manage.py start_portail
|
||||
ExecStart=/usr/bin/gunicorn3 portail_captif.wsgi:application --pid=/run/portail_captif.pid --name www-data --user www-data --group www-data --daemon --log-file /var/log/gunicorn/portail_captif.log --log-level=info --bind=unix:///tmp/gunicorn-portail_captif.sock --workers=1
|
||||
ExecReload=/bin/kill -s HUP $MAINPID
|
||||
ExecStop=/bin/kill -s TERM $MAINPID
|
||||
ExecStopPost=/usr/bin/python3 /var/www/portail_captif/portail_captif/stop_portail.py
|
||||
ExecStopPost=/usr/bin/python3 /var/www/portail_captif/manage.py stop_portail
|
||||
Restart=on-failure
|
||||
RestartSec=65
|
||||
StartLimitInterval=60
|
||||
|
@ -19,36 +19,26 @@
|
||||
# Ce script est appellé avant le démarage du portail, il insère les bonnes règles
|
||||
# dans l'iptables et active le routage
|
||||
|
||||
import os, sys
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
from os.path import dirname
|
||||
|
||||
proj_path = "/var/www/portail_captif/"
|
||||
# This is so Django knows where to find stuff.
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "portail_captif.settings")
|
||||
sys.path.append(proj_path)
|
||||
|
||||
# This is so my local_settings.py gets loaded.
|
||||
os.chdir(proj_path)
|
||||
|
||||
from users.models import restore_iptables, create_ip_set, fill_ipset, apply
|
||||
from portail_captif.settings import AUTORIZED_INTERFACES
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Mets en place iptables et le set ip au démarage'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# Creation de l'ipset
|
||||
create_ip_set()
|
||||
# Remplissage avec les macs autorisées
|
||||
fill_ipset()
|
||||
# Restauration de l'iptables
|
||||
restore_iptables()
|
||||
# Activation du routage sur les bonnes if
|
||||
for interface in AUTORIZED_INTERFACES:
|
||||
apply(["sudo", "-n", "sysctl", "net.ipv6.conf.%s.forwarding=1" % interface])
|
||||
apply(["sudo", "-n", "sysctl", "net.ipv4.conf.%s.forwarding=1" % interface])
|
||||
|
||||
application = get_wsgi_application()
|
||||
|
||||
# Creation de l'ipset
|
||||
create_ip_set()
|
||||
|
||||
# Remplissage avec les macs autorisées
|
||||
fill_ipset()
|
||||
|
||||
# Restauration de l'iptables
|
||||
restore_iptables()
|
||||
# Activation du routage sur les bonnes if
|
||||
for interface in AUTORIZED_INTERFACES:
|
||||
apply("echo 1 > /proc/sys/net/ipv6/conf/%s/forwarding" % interface)
|
||||
apply("echo 1 > /proc/sys/net/ipv4/conf/%s/forwarding" % interface)
|
||||
|
||||
|
@ -15,30 +15,27 @@
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
#
|
||||
# Ce script est appellé avant le démarage du portail, il insère les bonnes règles
|
||||
# dans l'iptables et active le routage
|
||||
|
||||
import os, sys
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
proj_path = "/var/www/portail_captif/"
|
||||
# This is so Django knows where to find stuff.
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "portail_captif.settings")
|
||||
sys.path.append(proj_path)
|
||||
|
||||
# This is so my local_settings.py gets loaded.
|
||||
os.chdir(proj_path)
|
||||
|
||||
from users.models import restore_iptables, apply
|
||||
from users.models import restore_iptables, create_ip_set, fill_ipset, disable_iptables, apply
|
||||
from portail_captif.settings import AUTORIZED_INTERFACES
|
||||
|
||||
# Destruction de l'iptables
|
||||
apply("iptables -t nat -F")
|
||||
apply("iptables -t filter -F")
|
||||
apply("iptables -t mangle -F")
|
||||
# Desactivation du routage sur les bonnes if
|
||||
for interface in AUTORIZED_INTERFACES:
|
||||
apply("echo 0 > /proc/sys/net/ipv6/conf/%s/forwarding" % interface)
|
||||
apply("echo 0 > /proc/sys/net/ipv4/conf/%s/forwarding" % interface)
|
||||
class Command(BaseCommand):
|
||||
help = 'Mets en place iptables et le set ip au démarage'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# Destruction de l'iptables
|
||||
disable_iptables()
|
||||
# Desactivation du routage sur les bonnes if
|
||||
for interface in AUTORIZED_INTERFACES:
|
||||
apply(["sudo", "-n", "sysctl", "net.ipv6.conf.%s.forwarding=0" % interface])
|
||||
apply(["sudo", "-n", "sysctl", "net.ipv4.conf.%s.forwarding=0" % interface])
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user