[K12OSN] Need a script

Jeff Kinz jkinz at kinz.org
Tue Mar 1 20:52:41 UTC 2005


On Tue, Mar 01, 2005 at 01:39:49PM -0700, Alan Hodson wrote:
> Hi folks
> 
> NEED: I am in dire need of a script that reads all users choosing only
> certain ones, then creates folders in the webserver area, set
> permissions and then creates a link back to the chosen user's home and
> renames it.
> 
> EXPLANATION: I have created accounts for all teachers on K12LTSP V.4.2
> servers (t.name##- a number based on the school code), and they all
> belong to a group called <tchr>
> 
> Manually, I am going into /var/www/html and creating a folder called
> t.name## (yes, one by one...). I then I set chmod 775 and chgrp tchr. I
> then make a link of this /var/www/html/t.name## and move it to the
> t.name## home area, where I rename it 'html' - this way, when a student
> types http://servername/t.name# they can see any and all documents that
> that teacher put in his/her <html> folder - I suggest to them to stay
> away from using index.html, as that turns off the listing of that
> 'storage/drop area'
> 
> I would like to see if a small script can a) read all user names and
> 'select' those ending with ## (school number, and only teachers) - b)
> create the folder in /var/www/html with that same name, c) set the
> permissions, d) make an alias of it in the original home directory and
> e) rename the alias to 'html', creating in effect a DROP FOLDER for all
> to see via the apache web server...

Assuming all teacher names end in two digits and none of the students
account names do this one liner may work:

for teach in `cat /etc/passwd | awk '{FS=":";}{print $1}' | \ 
egrep "[0-9][0-9]" ` ; do dir=/var/www/html/${teach}; mkdir $dir;\
chmod 775 $dir ; cd /home/${teach}; ln -s $dir ${teach}.html; done

not tested or debugged, use at own risk, beware of gnats etc..


-- 
Linux/Open Source:  Your infrastructure belongs to you, free, forever.
Idealism:  "Realism applied over a longer time period"
http://www.scaled.com/projects/tierone/
http://kinz.org
http://www.fedoratracker.org http://www.fedorafaq.org
http://www.fedoranews.org
Jeff Kinz, Emergent Research, Hudson, MA.




More information about the K12OSN mailing list