Hi all
I'm trying to create an extension attribute that checks all available network interfaces to see if a proxy is enabled or not, and then use the AE with a policy to disable or enable the proxy dependent on the Mac's building location.
At the moment the script i have returns the status of each individual interface and when used as an extension attribute it will only show the status of the last port checked, can anyone advise how i'd get the script to look at all the results then echo "yes" if they are all on and "no" if any of them are off ?
<result>on</result>
<result>on</result>
<result>on</result>
<result>off</result>
<result>on</result>
<result>on</result>
<result>on</result> = off
and
<result>on</result>
<result>on</result>
<result>on</result>
<result>on</result>
<result>on</result>
<result>on</result>
<result>on</result> = on
this is what i have so far
#!/bin/sh
#Declaring Variables
Ethernet=`/usr/sbin/networksetup -getautoproxyurl "Ethernet" | grep -x "Enabled: Yes"`
WiFi=`/usr/sbin/networksetup -getautoproxyurl "Wi-Fi" | grep -x "Enabled: Yes"`
USBEthernet=`/usr/sbin/networksetup -getautoproxyurl "USB Ethernet" | grep -x "Enabled: Yes"`
Broadcom_NetXtreme_Gigabit_Ethernet_Controller=`/usr/sbin/networksetup -getautoproxyurl "Broadcom NetXtreme Gigabit Ethernet Controller" | grep -x "Enabled: Yes"`
Display_Ethernet=`/usr/sbin/networksetup -getautoproxyurl "Display Ethernet" | grep -x "Enabled: Yes"`
Thunderbolt_Bridge=`/usr/sbin/networksetup -getautoproxyurl "Thunderbolt Bridge" | grep -x "Enabled: Yes"`
Thunderbolt_Ethernet=`/usr/sbin/networksetup -getautoproxyurl "Thunderbolt Ethernet" | grep -x "Enabled: Yes"`
#Checking Ethernet status
if [ "$Ethernet" = "Enabled: Yes" ]; then
echo "<result>on</result>"
else
echo "<result>off</result>"
fi
#Checking WiFi status
if [ "$WiFi" = "Enabled: Yes" ]; then
echo "<result>on</result>"
else
echo "<result>off</result>"
fi
#Checking USBEthernet status
if [ "$USBEthernet" = "Enabled: Yes" ]; then
echo "<result>on</result>"
else
echo "<result>off</result>"
fi
#Checking Broadcom_NetXtreme_Gigabit_Ethernet_Controller status
if [ "$Broadcom_NetXtreme_Gigabit_Ethernet_Controller" = "Enabled: Yes" ]; then
echo "<result>on</result>"
else
echo "<result>off</result>"
fi
#Checking Display_Ethernet status
if [ "$Display_Ethernet" = "Enabled: Yes" ]; then
echo "<result>on</result>"
else
echo "<result>off</result>"
fi
#Checking Thunderbolt_Bridge status
if [ "$Thunderbolt_Bridge" = "Enabled: Yes" ]; then
echo "<result>on</result>"
else
echo "<result>off</result>"
fi
#Checking Thunderbolt_Ethernet status
if [ "$Thunderbolt_Ethernet" = "Enabled: Yes" ]; then
echo "<result>on</result>"
else
echo "<result>off</result>"
fi
Thanks,
Andy