#!/bin/bash #Script to figure out why a user's website isn't working #Copyright Brian Brazil 2004,2005 #[ -z $USER ] && echo 'Usage: website-working ' && exit 1 USER=$(whoami) [ -z $1 ] || USER=$1 echo "lynx --dump "http://www.netsoc.tcd.ie/~$USER/" | head -10" lynx -reload --dump "http://www.netsoc.tcd.ie/~$USER/" | head -10 echo ---------------------------------------------------- #Check they haven't been bad and their webspace disabled #OUT=`grep -E "^[^#]*UserDir +disable(([a-z1-9]+)? )+$USER($| )" /etc/apache/userdir.bad` #RESULT=$? #if [ $RESULT -eq 0 ]; then # echo # echo "Error: User '$USER' found in /etc/apache/userdir.bad: \"$OUT\"" # echo "Webspace has been disabled by an admin, probably for abuse" # exit 2 #else # echo "User '$USER' not found disabled in /etc/apache/userdir.bad - good" #fi #Is it a system account (e.g. root) and disabled for that reason? OUT=`grep -E "^[^#]*UserDir +disable(([a-z1-9]+)? )+$USER($| )" /etc/apache2/httpd-user.conf` RESULT=$? if [ $RESULT -eq 0 ]; then echo echo "Error: User '$USER' found in /etc/apache2/httpd.conf: \"$OUT\"" echo "Webspace has been disabled, probably for being a system account" exit 2 else echo "User '$USER' not found disabled in /etc/apache2/httpd.conf - good" fi #Show any lines containg the username (as a word) in httpd-user.conf grep -EHw "$USER" /etc/apache2/httpd-user.conf /etc/apache2/httpd.conf #Check webspace is disabled OUT=`egrep -i "^userdir disable $USER( \#.*)?$" /etc/apache/userdir.disable` RESULT=$? if [ $RESULT -eq 0 ]; then echo "Error: User '$USER' found in /etc/apache/userdir.disable: \"$OUT\"" echo "Maybe they haven't renewed their account" exit 2 else echo "User '$USER' not found in /etc/apache/userdir.disable - good" fi #Check webspace is enabled OUT=`grep -ix "UserDir enabled $USER" /etc/apache/userdir.conf` RESULT=$? if [ $RESULT -eq 1 ]; then echo "Error: User '$USER' not found in /etc/apache/userdir.conf" echo "Maybe they should run 'accept_waup.pl'" exit 2 else echo "User '$USER' found in /etc/apache/userdir.conf: \"$OUT\"" fi echo echo "www Directory contents:" ls -lA /home/$USER/www/ echo echo "Permissions: (don't forget to check ACLs - if any)" ls -ld /home/$USER/ ls -ld /home/$USER/www/ if find /home/$USER -maxdepth 0 -not -perm +001 | fgrep "/home/$USER" > /dev/null; then echo "***Warning*** - /home/$USER not world executable" fi; if find /home/$USER/www -maxdepth 0 -not -perm +001 | fgrep "/home/$USER/www" > /dev/null; then echo "***Warning*** - /home/$USER/www not world executable" fi; RESULT=$(find /home/$USER/www/. -maxdepth 1 -name 'index.*' -type f -not -perm +004) if [ -n "$RESULT" ]; then echo "***Warning*** - the following index files are not world readable:" echo $RESULT fi #inaccessable or bad .htaccess can mess thing up ls -l /home/$USER/www/.htaccess 2>/dev/null sed -e "s/^/\/home\/$USER\/www\/.htaccess Contents: /" /home/$USER/www/.htaccess 2>/dev/null echo echo "This progam can't detect all problems." echo "You must get special permission to serve .mp3s, .avis etc."