#!/opt/bin/perl ########################################################################### # # # Program to install WWW home directory and home page for caller # # # ########################################################################### # # # Version 1.0.1 - Written 06.11.95 by Steffen Beyer # # # ########################################################################### # # # Copyright (C) 1995 by software design & management GmbH & Co. KG # # # ########################################################################### # # Some defaults: # $version = "version 1.0.1"; # $self = $0; # if ($self =~ m!/([^/]+)$!) { $self = $1; } # # Who am I? # ($user,$name,$dir) = (getpwuid($<))[0,6,7]; # # "Clean" the name entry from superfluous information: # $name =~ s/[\t\r\n\f]/ /g; $name =~ s/ +/ /g; $name =~ s/^\s*//; $name =~ s/\s*$//; $name =~ s/\s*\(.*\)\s*$//; $name =~ s/^Dr\.(\S)/Dr. $1/; # # Check existence of user's home directory: # unless (-d $dir) { die "$self error: directory '$dir' does not exist!\n"; } # # Check permissions on user's home directory: # if (((stat($dir))[2] % 01000) != 0755) { warn "$self warning: permissions of directory '$dir' are not 'drwxr-xr-x'!\n"; if (chmod (0755,"$dir") != 1) { die "$self error: can't chmod directory '$dir' to 'drwxr-xr-x'!\n"; } } # # Check if WWW home directory already exists: # if (-e "$dir/.www") { if (-d "$dir/.www") { warn "$self warning: directory '$dir/.www' already exists!\n"; if (((stat("$dir/.www"))[2] % 01000) != 0755) { warn "$self warning: permissions of directory '$dir/.www' are not 'drwxr-xr-x'!\n"; if (chmod (0755,"$dir/.www") != 1) { die "$self error: can't chmod directory '$dir/.www' to 'drwxr-xr-x'!\n"; } } } else { die "$self error: file '$dir/.www' already exists!\n"; } } else { unless (mkdir ("$dir/.www",0755)) { die "$self error: can't create directory '$dir/.www': $!\n"; } } # # Check if home page document already exists: # if (-e "$dir/.www/index.html") { if (-f "$dir/.www/index.html") { warn "$self warning: file '$dir/.www/index.html' already exists!\n"; $exists = 1; } else { die "$self error: file '$dir/.www/index.html' already exists!\n"; } } else { unless (open(HOMEPAGE, ">$dir/.www/index.html")) { die "$self error: can't create file '$dir/.www/index.html': $!\n"; } print HOMEPAGE <<"EOF"; Homepage von $name

Homepage von $name

This Is ${name}'s Complete Waste Of Time...


$name - $user\@sdm.de
EOF close(HOMEPAGE); } # # Check file permissions on user's home page: # if (((stat("$dir/.www/index.html"))[2] % 01000) != 0644) { if ($exists) { warn "$self warning: permissions of file '$dir/.www'/index.html are not '-rw-r--r--'!\n"; } if (chmod (0644,"$dir/.www/index.html") != 1) { die "$self error: can't chmod file '$dir/.www/index.html' to '-rw-r--r--'!\n"; } } # # Done. #