Stopping ~/Sites from being browsable via AFP and setting up WebDAV areas.

More requests from X-World…

We use ~/Sites for personal web pages. I don't really like the way that by default other users can browse this folder via AFP, and you can't fix this by modifying the User Template folder, so I run this script every night on all network home directories.

This same script also makes sure that each user has a folder ~/Sites/calendars that has the correct permissions such that they can use iCal to publish to this location.

You'll notice that I'm doing this by looping over the contents of a network home directory share point. I do this because my users are treated differently based upon where their home directories are, and not all sharepoints contain users that will automatically get a ~/Sites/calendars folder.

You could modify this to instead loop over all users from Directory Services, but that's unnecessary overhead in my case. Post a comment if you'd like to see what that script would look like.

#!/bin/bash
#
cd /Volumes/path/to/staff/homes
for user in $(ls | grep -e "^[a-z]")
do
        chown -R $user:www $user/Sites
        chmod -R 750 $user/Sites
        mkdir -p $user/Sites/calendars
        chown -R www:www $user/Sites/calendars
        chmod -R 770 $user/Sites/calendars
done

NB: The next entry I'll have up tomorrow or maybe tonight will describe how I'm automatically creating Apache WebDAV realms for the ~/Sites/calendars location, as that's the bit people seem to be mailing me about…

Leave a Reply

Name and Email Address are required fields. Your email will not be published or shared with third parties.