mirror of
https://github.com/grahampugh/macadmin-scripts.git
synced 2025-12-18 10:16:37 +00:00
Add test for remotectl command for older Macs
This commit is contained in:
parent
9a53656ebf
commit
1283058653
@ -81,7 +81,7 @@ def get_board_id():
|
|||||||
|
|
||||||
def is_a_vm():
|
def is_a_vm():
|
||||||
"""Determines if the script is being run in a virtual machine"""
|
"""Determines if the script is being run in a virtual machine"""
|
||||||
sysctl_cmd = ["/usr/sbin/sysctl", "machdep.cpu.features"]
|
sysctl_cmd = ["/usr/sbin/sysctl", "-n", "machdep.cpu.features"]
|
||||||
try:
|
try:
|
||||||
sysctl_output = subprocess.check_output(sysctl_cmd)
|
sysctl_output = subprocess.check_output(sysctl_cmd)
|
||||||
cpu_features = sysctl_output.decode("utf8").split(" ")
|
cpu_features = sysctl_output.decode("utf8").split(" ")
|
||||||
@ -96,26 +96,32 @@ def is_a_vm():
|
|||||||
|
|
||||||
def get_hw_model():
|
def get_hw_model():
|
||||||
"""Gets the local system ModelIdentifier"""
|
"""Gets the local system ModelIdentifier"""
|
||||||
sysctl_cmd = ["/usr/sbin/sysctl", "hw.model"]
|
sysctl_cmd = ["/usr/sbin/sysctl", "-n", "hw.model"]
|
||||||
try:
|
try:
|
||||||
sysctl_output = subprocess.check_output(sysctl_cmd)
|
sysctl_output = subprocess.check_output(sysctl_cmd)
|
||||||
hw_model = sysctl_output.decode("utf8").split(" ")[-1].split("\n")[0]
|
hw_model = sysctl_output.decode("utf8")
|
||||||
except subprocess.CalledProcessError as err:
|
except subprocess.CalledProcessError as err:
|
||||||
raise ReplicationError(err)
|
raise ReplicationError(err)
|
||||||
return hw_model
|
return hw_model
|
||||||
|
|
||||||
|
|
||||||
def get_bridge_id():
|
def get_bridge_id():
|
||||||
"""Gets the local system DeviceID for T2 Macs"""
|
"""Gets the local system DeviceID for T2 Macs - note only works on 10.13+"""
|
||||||
remotectl_cmd = ["/usr/libexec/remotectl", "get-property", "localbridge", "HWModel"]
|
if os.path.exists("/usr/libexec/remotectl"):
|
||||||
try:
|
remotectl_cmd = [
|
||||||
remotectl_output = subprocess.check_output(
|
"/usr/libexec/remotectl",
|
||||||
remotectl_cmd, stderr=subprocess.STDOUT
|
"get-property",
|
||||||
)
|
"localbridge",
|
||||||
bridge_id = remotectl_output.decode("utf8").split(" ")[-1].split("\n")[0]
|
"HWModel",
|
||||||
except subprocess.CalledProcessError as err:
|
]
|
||||||
return None
|
try:
|
||||||
return bridge_id
|
remotectl_output = subprocess.check_output(
|
||||||
|
remotectl_cmd, stderr=subprocess.STDOUT
|
||||||
|
)
|
||||||
|
bridge_id = remotectl_output.decode("utf8").split(" ")[-1].split("\n")[0]
|
||||||
|
except subprocess.CalledProcessError as err:
|
||||||
|
return None
|
||||||
|
return bridge_id
|
||||||
|
|
||||||
|
|
||||||
def get_current_build_info():
|
def get_current_build_info():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user