mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
ipv6 support webui
Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
@ -44,7 +44,8 @@ class Server:
|
|||||||
CSRFProtect(app)
|
CSRFProtect(app)
|
||||||
Handler(self._config, self._agent, app)
|
Handler(self._config, self._agent, app)
|
||||||
|
|
||||||
logging.info("web ui available at http://%s:%d/" % (self._address, self._port))
|
formatServerIpAddress = '[::]' if self._address == '::' else self._address
|
||||||
|
logging.info("web ui available at http://%s:%d/" % (formatServerIpAddress, self._port))
|
||||||
|
|
||||||
app.run(host=self._address, port=self._port, debug=False)
|
app.run(host=self._address, port=self._port, debug=False)
|
||||||
else:
|
else:
|
||||||
|
52
setup.py
52
setup.py
@ -1,30 +1,31 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
from distutils.util import strtobool
|
from setuptools.command.install import install
|
||||||
import os
|
|
||||||
import glob
|
import glob
|
||||||
import shutil
|
import logging
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
import shutil
|
||||||
|
import warnings
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
def install_file(source_filename, dest_filename):
|
def install_file(source_filename, dest_filename):
|
||||||
# do not overwrite network configuration if it exists already
|
# do not overwrite network configuration if it exists already
|
||||||
# https://github.com/evilsocket/pwnagotchi/issues/483
|
# https://github.com/evilsocket/pwnagotchi/issues/483
|
||||||
if (dest_filename.startswith('/etc/network/interfaces.d/') or dest_filename.startswith('/root/')
|
if dest_filename.startswith('/root/') and os.path.exists(dest_filename):
|
||||||
and os.path.exists(dest_filename)):
|
log.info(f"{dest_filename} exists, skipping ...")
|
||||||
print("%s exists, skipping ..." % dest_filename)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
print("installing %s to %s ..." % (source_filename, dest_filename))
|
log.info(f"installing {source_filename} to {dest_filename} ...")
|
||||||
try:
|
|
||||||
dest_folder = os.path.dirname(dest_filename)
|
dest_folder = os.path.dirname(dest_filename)
|
||||||
if not os.path.isdir(dest_folder):
|
if not os.path.isdir(dest_folder):
|
||||||
os.makedirs(dest_folder)
|
os.makedirs(dest_folder)
|
||||||
|
|
||||||
shutil.copy2(source_filename, dest_filename)
|
shutil.copyfile(source_filename, dest_filename)
|
||||||
except Exception as e:
|
if dest_filename.startswith("/usr/bin/"):
|
||||||
print("error installing %s: %s" % (source_filename, e))
|
os.chmod(dest_filename, 0o755)
|
||||||
|
|
||||||
|
|
||||||
def install_system_files():
|
def install_system_files():
|
||||||
@ -36,16 +37,27 @@ def install_system_files():
|
|||||||
dest_filename = source_filename.replace(data_path, '')
|
dest_filename = source_filename.replace(data_path, '')
|
||||||
install_file(source_filename, dest_filename)
|
install_file(source_filename, dest_filename)
|
||||||
|
|
||||||
|
|
||||||
|
def restart_services():
|
||||||
# reload systemd units
|
# reload systemd units
|
||||||
os.system("systemctl daemon-reload")
|
os.system("systemctl daemon-reload")
|
||||||
|
|
||||||
|
|
||||||
def installer():
|
|
||||||
install_system_files()
|
|
||||||
# for people updating https://github.com/evilsocket/pwnagotchi/pull/551/files
|
# for people updating https://github.com/evilsocket/pwnagotchi/pull/551/files
|
||||||
os.system("systemctl enable fstrim.timer")
|
os.system("systemctl enable fstrim.timer")
|
||||||
|
|
||||||
|
|
||||||
|
class CustomInstall(install):
|
||||||
|
def run(self):
|
||||||
|
super().run()
|
||||||
|
if os.geteuid() != 0:
|
||||||
|
warnings.warn(
|
||||||
|
"Not running as root, can't install pwnagotchi system files!"
|
||||||
|
)
|
||||||
|
return
|
||||||
|
install_system_files()
|
||||||
|
restart_services()
|
||||||
|
|
||||||
|
|
||||||
def version(version_file):
|
def version(version_file):
|
||||||
with open(version_file, 'rt') as vf:
|
with open(version_file, 'rt') as vf:
|
||||||
version_file_content = vf.read()
|
version_file_content = vf.read()
|
||||||
@ -57,11 +69,12 @@ def version(version_file):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
if strtobool(os.environ.get("PWNAGOTCHI_ENABLE_INSTALLER", "1")):
|
|
||||||
installer()
|
|
||||||
|
|
||||||
with open('requirements.txt') as fp:
|
with open('requirements.txt') as fp:
|
||||||
required = [line.strip() for line in fp if line.strip() != ""]
|
required = [
|
||||||
|
line.strip()
|
||||||
|
for line in fp
|
||||||
|
if line.strip() and not line.startswith("--")
|
||||||
|
]
|
||||||
|
|
||||||
VERSION_FILE = 'pwnagotchi/_version.py'
|
VERSION_FILE = 'pwnagotchi/_version.py'
|
||||||
pwnagotchi_version = version(VERSION_FILE)
|
pwnagotchi_version = version(VERSION_FILE)
|
||||||
@ -74,6 +87,9 @@ setup(name='pwnagotchi',
|
|||||||
url='https://pwnagotchi.ai/',
|
url='https://pwnagotchi.ai/',
|
||||||
license='GPL',
|
license='GPL',
|
||||||
install_requires=required,
|
install_requires=required,
|
||||||
|
cmdclass={
|
||||||
|
"install": CustomInstall,
|
||||||
|
},
|
||||||
scripts=['bin/pwnagotchi'],
|
scripts=['bin/pwnagotchi'],
|
||||||
package_data={'pwnagotchi': ['defaults.yml', 'pwnagotchi/defaults.yml', 'locale/*/LC_MESSAGES/*.mo']},
|
package_data={'pwnagotchi': ['defaults.yml', 'pwnagotchi/defaults.yml', 'locale/*/LC_MESSAGES/*.mo']},
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
|
Reference in New Issue
Block a user