#!/usr/bin/env bash set -u #set -x DESC="Test apache2 (serveur:bigboss et client:tiny)" HELP=" Bigboss et tiny doivent avoir été configurés par baseConfig. ATTENTION, les fichiers suivants sont modifiés : - /etc/apache2/apache2.conf - /etc/apache2/sites-available/000-default.conf " testApache2Base() { echo "bigboss run apache2 ?" vdn-ssh root@tiny "netcat -w 1 bigboss 80 &> /dev/null < /dev/null" #vdn-ssh root@tiny "lynx -dump bigboss &> /dev/null" e=$?; [ $e = 0 ] && green ok || red ko errors=$((errors+$e)) return $e } testApache2Root() { vdn-ssh root@tiny " lynx -dump bigboss/index.html | \ grep -q -i 'Bonjour' " vdn-ssh root@tiny " lynx -dump bigboss/index.html | grep -q 'ok' && echo ok " } testApache2CGI() { vdn-ssh root@tiny " lynx -dump bigboss/cgi-bin/test-cgi lynx -dump bigboss/cgi-bin/test-cgi | grep -q 'Bonjour' " } testApache2Php() { vdn-ssh root@tiny " lynx -dump bigboss/index.php lynx -dump bigboss/index.php | grep -q 'sommes le [^,]' " } testApache2Home() { echo "bigboss run apache2 with userdir ?" vdn-ssh root@tiny " unset http_proxy; lynx -dump bigboss/~toto 2> /dev/null # | grep -iq 'perso' " e=$?; [ $e = 0 ] && green ok || red ko errors=$((errors+$e)) return $e } testApache2HtaccessExist() { echo "toto@bigboss possède un répertoire HTTP protégé ?" vdn-ssh root@bigboss " find /home/toto/public_html -name '.htaccess' 2> /dev/null | grep -q 'htaccess$' " e=$?; [ $e = 0 ] && green ok || red ko errors=$((errors+$e)) return $e } testApache2HtaccessToto() { echo "toto@bigboss : répertoire HTTP fonctionnel ?" vdn-ssh root@tiny " unset http_proxy; lynx -dump http://bigboss/~toto/index.html " } testApache2Htaccess() { vdn-ssh root@tiny " echo \"Accès à privé sans identification\" lynx -dump bigboss/prive | grep -q 'Prive' && \ echo \"ok\" echo echo \"Accès à privé sans identification\" lynx -dump bigboss/prive/.htaccess | grep -q 'Forbidden' " vdn-ssh root@tiny " echo \"Accès à privé sans identification\" lynx -dump bigboss/prive 2> /dev/null | grep -q 'Prive' || \ echo \"ok\" echo echo \"Accès à privé avec identification\" lynx -auth=sasa:xyz -dump bigboss/prive | \ grep -q 'Prive' " } run() { local errors=0 e setErrorHandler echoStart requireSshGuests bigboss tiny testApache2Base e=$? #testApache2Root #testApache2CGI #testApache2Php if [ $e = 0 ]; then testApache2Home testApache2HtaccessExist #testApache2HtaccessToto else echo "Subsequent tests canceled !" >&2 fi #testApache2Htaccess unsetErrorHandler return $errors }