fix: don't reset network interfaces configuration if not needed (closes #483)

This commit is contained in:
Simone Margaritelli 2019-11-01 12:12:37 +01:00
parent e06f2a32e8
commit ae330dc0b5

View File

@ -5,25 +5,39 @@ import os
import glob
import shutil
setup_path = os.path.dirname(__file__)
data_path = os.path.join(setup_path, "builder/data")
for source_filename in glob.glob("%s/**" % data_path, recursive=True):
if os.path.isfile(source_filename):
dest_filename = source_filename.replace(data_path, '')
def install_file(source_filename, dest_filename):
# do not overwrite network configuration if it exists already
# https://github.com/evilsocket/pwnagotchi/issues/483
if dest_filename.startswith('/etc/network/interfaces.d/') and os.path.exists(dest_filename):
print("%s exists, skipping ..." % dest_filename)
return
print("installing %s to %s ..." % (source_filename, dest_filename))
try:
dest_folder = os.path.dirname(dest_filename)
if not os.path.isdir(dest_folder):
os.makedirs(dest_folder)
print("installing %s to %s ..." % (source_filename, dest_filename))
try:
if not os.path.isdir(dest_folder):
os.makedirs(dest_folder)
shutil.copyfile(source_filename, dest_filename)
except Exception as e:
print("error installing %s: %s" % (source_filename, e))
shutil.copyfile(source_filename, dest_filename)
except Exception as e:
print("error installing %s: %s" % (source_filename, e))
# reload systemd units
os.system("systemctl daemon-reload")
def install_system_files():
setup_path = os.path.dirname(__file__)
data_path = os.path.join(setup_path, "builder/data")
for source_filename in glob.glob("%s/**" % data_path, recursive=True):
if os.path.isfile(source_filename):
dest_filename = source_filename.replace(data_path, '')
install_file(source_filename, dest_filename)
# reload systemd units
os.system("systemctl daemon-reload")
install_system_files()
required = []
with open('requirements.txt') as fp: