4.5 Shell Script - Creating SharePoints & automounts

A SharePoint is any folder on the server whose contents you would like shared between different users on the network. Share points are generally available from the "Go" menu in Mac OS X, and from the "Chooser" in Mac OS 9 and earlier.

An auto-mount is a NetInfo definition that allows OS X clients to automatically mount a SharePoint as part of the clients' file system during user log in (Usually in /Network/Servers). This allows users to access files from another machine without being presented with a log-in window.

The following describes using shell scripts to create SharePoints and auto-mounts

Log in as "root" to the server that hosts the NetInfo master.  
Copy the script "mkmounts.sh" into roots' home directory (/private/var/root/Documents).  
Start a new shell.  

Change directory to roots' home directory, type:

cd ~/Documents

 

Make sure that the execute flag is set on the script "mkusers.sh" by typing:

chmod u+x mkmounts.sh

 
Launch a text editor.  

The "TextEdit" application defaults to "RTF" for new files.

To change the defaults to plain text, select "Preferences..." from the "TextEdit" menu.

 
Click on the "Plain text" radio button, then close down preferences.  
Create a new file.  

Create a text file containing a line for every mount that gives the following information:

machine_name,machine_ip,share_path

 
Save the file as "mounts.txt" in roots' home directory.  
Quit the editor.  

Execute the "mkmounts.sh" script and pass it the file "mounts.txt" as a parameter by typing the following:

~/Documents/mkmounts.sh mounts.txt

The script will create Mac OS X netinfo mount entries for every share specified in the file.

The shares defined in the file can reside on any server that can host afp: services.

 

NetInfo mounts allow OS X clients to automatically mount a share-point as part of the clients' file system during user log in (Usually in /Network/Servers).

This allows users to access afp-served files from a client machine without being presented with a log-in window.

If you are auto-mounting share points that reside on a Mac OS X machine, then you can use scripts as described below, to create the share points and appropriate folders.

You should run these scripts on every machine that you defined in the "mounts.txt" file.

First, copy the script "mkshares.sh" into roots' home directory (/private/var/root/Documents).
 

Make sure that the execute flag is set on the script "mkusers.sh" by typing:

chmod u+x mkshares.sh

 

Execute the "mkshares.sh" script by typing the following:

~/Documents/mkshares.sh

This script runs through the list of mounts specified in netinfo. The script creates a SharePoint whenever it finds a mount definition for the machine that the script is running on.

It cannot create SharePoints for other machine mounts, since SharePoints are defined in a machines local NetInfo database.

 

Now that the SharePoints are defined, we need to make sure that all the folders required by the SharePoint are available.

Copy the script "mksharefldrs.sh" into roots' home directory (/private/var/root/Documents).

 

Execute the "mksharefldrs.sh" script by typing the following:

~/Documents/mksharefldrs.sh

This script will create the share folder and any required subfolders for every SharePoint specified by netinfo.

 
 
Folders created within the share folder include:

"Temporary Items" (u=r/w,g=r/w,o=r/w) (required by Adobe Photoshop)
"Network Trash Folder" (u=r/w,g=r/w,o=r/w)
"Users" (u=r/w,g=r/w,o=r)
"Users/Groups Folder" (u=r/w,g=r/w,o=r)
"Managed Preferences" (u=r/w,g=r/w,o=r)
"Managed Preferences/Initial Preferences" (u=r/w,g=r/w,o=r)
"Managed Preferences/Forced Preferences" (u=r/w,g=r/w,o=r)
"Managed Preferences/Preserved Preferences" (u=r/w,g=r/w,o=r)
(u=administrator,g=wheel)

Note, giving everyone r/w access to the folders "Temporary Items" and "Network Trash Folder" is a risk. This is especially true if you have afp, smb or ftp guest access enabled. Consider using a cron script every night to purge these temporary folders of their contents.

Mac OSX server - tech notes - © 2002 by Mark J Swift - msw AT blackpool.ac.uk