diff --git a/src/web/pi_cmds.py b/src/web/pi_cmds.py index 28f19260..db34ae9e 100644 --- a/src/web/pi_cmds.py +++ b/src/web/pi_cmds.py @@ -51,15 +51,16 @@ def running_env(): return {"git": ra_git_version, "env": pi_version} -def running_netatalk(): +def running_proc(daemon): """ - Returns (int) afpd, which is the number of afpd processes currently running + Takes (str) daemon + Returns (int) proc, which is the number of processes currently running """ process = subprocess.run(["ps", "aux"], capture_output=True) output = process.stdout.decode("utf-8") from re import findall - afpd = findall("afpd", output) - return len(afpd) + proc = findall(daemon, output) + return len(proc) def is_bridge_setup(): @@ -82,6 +83,24 @@ def disk_space(): total, used, free = disk_usage(__file__) return {"total": total, "used": used, "free": free} + +def get_ip_address(): + """ + Use a mock socket connection to identify the Pi's IP address + """ + from socket import socket, AF_INET, SOCK_DGRAM + sock = socket(AF_INET, SOCK_DGRAM) + try: + # mock ip address; doesn't have to be reachable + sock.connect(('10.255.255.255', 1)) + ip_addr = sock.getsockname()[0] + except Exception: + ip_addr = '127.0.0.1' + finally: + sock.close() + return ip_addr + + def introspect_file(file_path, re_term): """ Takes a (str) file_path and (str) re_term in regex format @@ -96,4 +115,4 @@ def introspect_file(file_path, re_term): for line in ifile: if match(re_term, line): return True - return False + return False \ No newline at end of file diff --git a/src/web/templates/index.html b/src/web/templates/index.html index 233d60c4..5fa7877b 100644 --- a/src/web/templates/index.html +++ b/src/web/templates/index.html @@ -317,6 +317,11 @@ +{% if macproxy_configured %} +
macproxy is running at {{ ip_addr }} port 5000
+{% else %} +Install macproxy to browse the Web with your vintage browser.
+{% endif %}