The script continues to run the else statement even if ARD is enabled. Can't figure out how to exit if $ardstatus = enabled
#!/bin/sh
#check if users have ARD enabled or disabled
ardstatus="echo `cat /private/etc/RemoteManagement.launchd`"
if [ "$ardstatus" = enabled ]; then
echo "ARD is enabled"
else
#if disabled enable it for specifiedUsers which is determined in the next command
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -allowAccessFor -specifiedUsers
#configure ARD
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -users admin,administrator -access -on -privs -ControlObserve -ObserveOnly -TextMessages
fi
so that means that what is coming out in ardstatus has more than you think, most likely a new-line char. Try this
ardstatus=$( < /private/etc/RemoteManagement.launchd )
If that doesn't fix it, then 'inspect' your variable
echo "ardstatus=XXX${ardstatus}XXX"
This assumes a bash or ksh like shell, if you really have a bourne shell, then you'll need to continue to use back-tics for cmd-substitution. If you need that, you still don't need the echo, so do
ardstatus="`cat /private/etc/RemoteManagement.launchd`"
and use the inspect code above.
I hope this helps.