Enable/Disable File Sharing

armando
New Contributor III

Does anybody know of a way I can enable and disable file sharing using casper?

I tried the enableFileSharing.sh -- (Enables or Disables Personal File Sharing on Mac OS X Clients) from the resource kit but it does not seem to be working on 10.6 or 10.7 machines.

When I set the parameter to YES I get this

Running Script enableFileSharing.sh...
Script Exit Code:1
Script Result: Enabling File Sharing for OS 10.6 ...
nothing found to load
Unmounting file server...
Submitting log to https://mycasper.com:8443//...
Finished.

Any ideas?

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor II

Hmm, based on that error, it looks like the script is having a problem with line 149, the launchctl command to load the AppleFileServer daemon-

/bin/launchctl load /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist;;

I tried the same command by itself in Terminal on my 10.7 machine and also got the "nothing found to load" error. In looking at the actual plist, I'm not sure what the issue might be

Edit: Taking another look, it seems if you add the force flag, -F to the launchctl command, it appears to work. In other words, change that line 149 to read:

/bin/launchctl load -F /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist;;

After doing this, running:

sudo launchctl list | grep AppleFileServer

returns-

- 0 com.apple.AppleFileServer

Prior to that, the same command returned nothing.

II don't have a setup where I can verify if the services are properly enabled, so I would test this out, see if its actually turning it on, and test thoroughly before trying to push it to anything. I don't know that using the force flag is really a recommended way to do it, but at first glance it does seem to override whatever is keeping the process from starting up.

View solution in original post

6 REPLIES 6

mm2270
Legendary Contributor II

Hmm, based on that error, it looks like the script is having a problem with line 149, the launchctl command to load the AppleFileServer daemon-

/bin/launchctl load /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist;;

I tried the same command by itself in Terminal on my 10.7 machine and also got the "nothing found to load" error. In looking at the actual plist, I'm not sure what the issue might be

Edit: Taking another look, it seems if you add the force flag, -F to the launchctl command, it appears to work. In other words, change that line 149 to read:

/bin/launchctl load -F /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist;;

After doing this, running:

sudo launchctl list | grep AppleFileServer

returns-

- 0 com.apple.AppleFileServer

Prior to that, the same command returned nothing.

II don't have a setup where I can verify if the services are properly enabled, so I would test this out, see if its actually turning it on, and test thoroughly before trying to push it to anything. I don't know that using the force flag is really a recommended way to do it, but at first glance it does seem to override whatever is keeping the process from starting up.

View solution in original post

jarednichols
Honored Contributor

The -F flag ignores the disabled key, which in the com.apple.AppleFileServer.plist file is set to true (at least on my 10.7.3 machine here is).

mm2270
Legendary Contributor II

I had a chance to test this on another box this morning, and it does turn the service on. I was able to connect to the Mac from another one using plain ol' filesharing. It just turns on all the defaults, like "Public folders", etc. so you need to specify separately what you want to actually share out.

Running the 'launchctl unload' command turns it back off.

The script in the Resource Kit is obviously a bit old, based on the OS versions they are testing for (10.4, 10.5)

Again, I don't know if there is a safer, more recommended way to do this now.

armando
New Contributor III

I actually tired it this morning and it worked great.

Thanks allot.

armando
New Contributor III

Is there anyway I can also have it check on and off "Share files and folders using SMB"?

and

How can I add and remove Shared Folder?

I want to thank you guys for your time and help.

NightFlight
New Contributor III

launchctl <load/unload> -w /System/Library/LaunchDaemons/com.apple.smbd.plist