Don't wrap in docker for little wrappers like ssh and telnet if the tool is available on the host

This commit is contained in:
InsanePrawn 2021-09-29 23:49:46 +02:00
parent 1d172ad635
commit f424e9ce8f
5 changed files with 15 additions and 6 deletions

View file

@ -2,12 +2,13 @@ import click
import subprocess
from logger import logging
from ssh import cmd_ssh
from wrapper import enforce_wrap
from wrapper import check_programs_wrap
@click.command(name='forwarding')
def cmd_forwarding():
enforce_wrap()
check_programs_wrap(['syctl', 'iptables'])
result = subprocess.run([
'sysctl',
'net.ipv4.ip_forward=1',

View file

@ -10,7 +10,7 @@ from config import config
from chroot import create_chroot
from joblib import Parallel, delayed
from distro import get_kupfer_local
from wrapper import enforce_wrap
from wrapper import enforce_wrap, check_programs_wrap
makepkg_env = os.environ.copy() | {
'LANG': 'C',
@ -539,7 +539,7 @@ def cmd_build(paths: list[str], force=False, arch='aarch64'):
@cmd_packages.command(name='clean')
def cmd_clean():
enforce_wrap()
check_programs_wrap('git')
result = subprocess.run([
'git',
'clean',

2
ssh.py
View file

@ -1,9 +1,11 @@
import subprocess
import click
from wrapper import check_programs_wrap
@click.command(name='ssh')
def cmd_ssh(cmd: list[str] = [], host: str = '172.16.42.1', user: str = 'kupfer', port: int = 22):
check_programs_wrap('ssh')
return subprocess.run([
'ssh',
'-o',

View file

@ -1,11 +1,11 @@
import subprocess
import click
from wrapper import enforce_wrap
from wrapper import check_programs_wrap
@click.command(name='telnet')
def cmd_telnet(hostname: str = '172.16.42.1'):
enforce_wrap()
check_programs_wrap('telnet')
subprocess.run([
'telnet',
hostname,

View file

@ -6,6 +6,7 @@ import uuid
import click
import logging
from config import config, dump_file as dump_config_file
from utils import programs_available
DOCKER_PATHS = {
'chroots': '/chroot',
@ -107,6 +108,11 @@ def enforce_wrap(no_wrapper=False):
wrap_docker()
def check_programs_wrap(programs):
if not programs_available(programs):
enforce_wrap()
nowrapper_option = click.option(
'--no-wrapper',
'no_wrapper',