Posted on 07-29-2015 10:47 AM
Does anyone know if it's possible to enable file sharing on all Macs in our office using a JSS policy or Config profile? I've done some research and I've seen some talk about scripts and putting a script in a policy but I'm not sure of that process. Thanks for the help in advance.
Posted on 07-29-2015 11:33 AM
This JAMF Nation article may point you in the right direction to develop your script, then you can just call it via a Policy at the determined interval.
Posted on 07-29-2015 11:42 AM
@andrew.nicholas Thank you for the suggestion. This is the script I have so far? Do you have any insight?
enableFileSharing=""
if [ "$4" != "" ] && [ "$enableFileSharing" == "" ]; then
enableFileSharing=$4
fi
if [ "$enableFileSharing" == "" ]; then
echo "Error: The parameter 'enableFileSharing' is blank. Please specify a value."
exit 1
fi
OS=/usr/bin/defaults read /System/Library/CoreServices/SystemVersion ProductVersion | awk '{print substr($1,1,4)}'
if [[ "$OS" < "10.5" ]]
then
case $enableFileSharing in "t" | "T" |"true" | "True" | "TRUE" | "y" | "Y" | "yes" | "Yes" | "YES")
echo "Enabling File Sharing for OS $OS ..."
### Write out AFPSERVER key to hostconfig
/usr/bin/sed 's/AFPSERVER=-NO-/AFPSERVER=-YES-/g' /private/etc/hostconfig > /tmp/hostconfig
### Replace old hostconfig with new /bin/mv /private/etc/hostconfig /private/etc/hostconfig.bac /bin/mv /tmp/hostconfig /private/etc/hostconfig /usr/sbin/chown root:admin /private/etc/hostconfig /bin/chmod 644 /private/etc/hostconfig
### Start AFP echo "Starting Personal File Sharing..." /usr/sbin/AppleFileServer;; "f" | "F" | "false" | "False" | "FALSE" | "n" | "N" | "no" | "No" | "NO") echo "Disabling File Sharing for OS $OS ..." ### Write out AFPSERVER key to hostconfig /usr/bin/sed 's/AFPSERVER=-YES-/AFPSERVER=-NO-/g' /private/etc/hostconfig > /tmp/hostconfig
### Replace old hostconfig with new /bin/mv /private/etc/hostconfig /private/etc/hostconfig.bac /bin/mv /tmp/hostconfig /private/etc/hostconfig /usr/sbin/chown root:admin /private/etc/hostconfig /bin/chmod 644 /private/etc/hostconfig
### Kill AFP
echo "Disabling Personal File Sharing..."
/usr/bin/killall AppleFileServer;;
esac
fi
if [[ "$OS" > "10.4" ]]
then
case $enableFileSharing in "t" | "T" |"true" | "True" | "TRUE" | "y" | "Y" | "yes" | "Yes" | "YES")
echo "Enabling File Sharing for OS $OS ..."
/bin/launchctl load -w /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist;;
"f" | "F" | "false" | "False" | "FALSE" | "n" | "N" | "no" | "No" | "NO")
echo "Disabling File Sharing for OS $OS ..."
/bin/launchctl unload -w /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist;;
esac
fi
Posted on 07-29-2015 12:19 PM
If thats the script straight from the Scripts page of JAMF Nation I imagine it would be fine but I would test first to ensure it works as expected.
Posted on 07-29-2015 12:49 PM
This part of the script will fail if run on Yosemite and up
OS=/usr/bin/defaults read /System/Library/CoreServices/SystemVersion ProductVersion | awk '{print substr($1,1,4)}'
Its been well posted about on other threads that many of JAMF's older scripts using this method of checking the OS version fall down when run on 10.10.