#!/bin/csh # The above line tells UNIX to use the "csh" # shell to interpret these commands. # # this script is designed to correctly change permissions on # documents for WWW publishing on MCS net # written by Peter W # freely distributable under GNU Public License terms # available http://www.mcs.net/~peterw/html/gpl.htm # # Version 1.5b modified 8 September 1996 # # 1.5b will creted the top HTML dir if it does # not exist yet (for clark.net) # 1.5a more verbose comments # revision 1.5 added support for multiple directories, # allowed for easy configuration # and no longer uses temporary files # SET VARIABLE VALUES set TRUE = 1 set FALSE = 0 # HDIR: the top of your web docs path # for many systems this wil be $HOME/public_html # the script will change the perms on both $HOME and $HDIR # For clark.net this is /ftp/pub/LoginID set HDIR = /ftp/pub/$USER # and what is your home page? set HPAGE = $HDIR/home.htm # what subdirectories are your docs in # (relative to HDIR) names separated by single spaces # To add another directory name, just put it inside # the string, eg set HTMDIRS = "html java images movies" # -- Note it is possible to change permissions on files # at the top of your home directory by including # the directory . (as in HTMDIRS = "html .") # BUT I recommend against it, as it will make # all your directories executable, and if ALLREAD # is set to $TRUE will make every file findable # and readable!!! set HTMDIRS = "." # OK, I use "." at clarknet b/c this is _not_ my home # directory, and I want everything here accessible! # make all files there readable? If FALSE, will only # change perms on files with extensions listed in MIMES # most folks would do fine to set this to $FALSE and # edit MIMES as appropriate set ALLREAD = $TRUE # if not all files are to be readable, what types _should_ be ? # --note that the script looks for files named # something.EXT where EXT is one of those listed below, # only if $ALLREAD (above) is false set MIMES = "htm html gif jpg jpeg class au aiff wav avi mov map" # allow read on your dirs in $HTMDIRS? (to let others see file lists) # Not necessary. Alllows visitor to get list of files if no # index.html exists; allows all MCS users to see file names # if logged into the shell (tho not necesarily read them; see # note on ALLREAD, above. set DIRREAD = $FALSE # make a sym link to your home page? # allows URL of http://www.mcs.net/~peterw/ , with # no filename specified; prevents directory listing set MAKEINDEX = $TRUE set INDEXNAME = $HDIR/index.html # for MCS: make a home.html so your page will show # on the list of subscriber pages ? set MAKEHOME = $TRUE set HOMENAME = $HDIR/home.html # for MCS: make an empty log file if one does not # exist already? set MAKELOG = $FALSE # As far as I know this feature is not supported at clark.net set LOGNAME = $HDIR/html.log # Change the perms on the homedir: #chmod a+x $HOME # and the HTML DIR: if (! -e $HDIR ) then mkdir $HDIR endif chmod a+x $HDIR # Look for the files to change perms on foreach FILEDIR ($HTMDIRS) # This says to give me each name in HTMDIRS, one at a time, # calling the current name FILEDIR if (! $ALLREAD) then # If we're not opening all files, then we need to # look for specific extensions: foreach EXT ($MIMES) # as above, goes through the list of extensions find $HDIR/$FILEDIR -type f -name \*.$EXT -exec chmod a+r \{\} \; # find everything that is a file in the # current directory which ends in the # current extension and run the command # chmod a+r # on it (Change so all can read) # Since "*", "{", "}", and ";" are "special" # characters, they are "escaped" with "\" end # Otherwise, just do it to all files we find: else find $HDIR/$FILEDIR -type f -exec chmod a+r \{\} \; endif end chmod a+r $HPAGE # Make our home.html and index.html sym links if ($MAKEINDEX && (! -e $INDEXNAME)) then # This says (NOT does-this-exist filename) ln -s $HPAGE $INDEXNAME endif if ($MAKEHOME && (! -e $HOMENAME)) then ln -s $HPAGE $HOMENAME endif foreach DIR ($HTMDIRS) if ($DIRREAD) then chmod a+rx $HDIR/$DIR find $HDIR/$DIR -type d -exec chmod a+rx \{\} \; # type d means directory else chmod a+x $HDIR/$DIR find $HDIR/$DIR -type d -exec chmod a+x \{\} \; endif end # the following three lines create an empty log file # if you don't already have one: if ($MAKELOG && (! -e $LOGNAME)) then echo -n >$LOGNAME endif