mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-06-26 02:18:21 -04:00
WIP: Add rootfs building and flashing and other misc commands
This commit is contained in:
parent
8886725971
commit
1f5357bca6
12 changed files with 410 additions and 11 deletions
38
forwarding.py
Normal file
38
forwarding.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
import click
|
||||
import subprocess
|
||||
from logger import *
|
||||
|
||||
|
||||
@click.command(name='forwarding')
|
||||
@verbose_option
|
||||
def cmd_forwarding(verbose):
|
||||
setup_logging(verbose)
|
||||
|
||||
result = subprocess.run(['sysctl', 'net.ipv4.ip_forward=1'])
|
||||
if result.returncode != 0:
|
||||
logging.fatal(f'Failed to enable ipv4 forward via sysctl')
|
||||
exit(1)
|
||||
|
||||
result = subprocess.run(['iptables', '-P', 'FORWARD', 'ACCEPT'])
|
||||
if result.returncode != 0:
|
||||
logging.fatal(f'Failed set iptables rule')
|
||||
exit(1)
|
||||
|
||||
result = subprocess.run(['iptables',
|
||||
'-A', 'POSTROUTING',
|
||||
'-t', 'nat',
|
||||
'-j', 'MASQUERADE',
|
||||
'-s', '172.16.42.0/24'])
|
||||
if result.returncode != 0:
|
||||
logging.fatal(f'Failed set iptables rule')
|
||||
exit(1)
|
||||
|
||||
result = subprocess.run(['ssh',
|
||||
'-o', 'GlobalKnownHostsFile=/dev/null',
|
||||
'-o', 'UserKnownHostsFile=/dev/null',
|
||||
'-o', 'StrictHostKeyChecking=no',
|
||||
'-t', 'kupfer@172.16.42.1',
|
||||
'sudo route add default gw 172.16.42.2'])
|
||||
if result.returncode != 0:
|
||||
logging.fatal(f'Failed to add gateway over ssh')
|
||||
exit(1)
|
Loading…
Add table
Add a link
Reference in a new issue