bstinson / centos / t_functional

Forked from centos/t_functional 4 years ago
Clone

Blame tests/p_httpd/httpd_vhost.sh

Karanbir Singh 0b5bb2
#!/bin/sh
Karanbir Singh 0b5bb2
# Author: Athmane Madjoudj <athmanem@gmail.com>
Karanbir Singh 0b5bb2
Karanbir Singh 0b5bb2
echo "127.0.0.1   test" >>  /etc/hosts
Karanbir Singh 0b5bb2
cat > /etc/httpd/conf.d/vhost-test.conf <
Karanbir Singh 0b5bb2
NameVirtualHost *:80
Karanbir Singh 0b5bb2
Karanbir Singh 0b5bb2
<VirtualHost *:80>
Karanbir Singh 0b5bb2
 ServerAdmin webmaster@test
Karanbir Singh 0b5bb2
 DocumentRoot /var/www/vhosts/test/
Karanbir Singh 0b5bb2
 ServerName test
Karanbir Singh 0b5bb2
</VirtualHost>
Karanbir Singh 0b5bb2
EOF
Karanbir Singh 0b5bb2
Karanbir Singh 0b5bb2
mkdir -p /var/www/vhosts/test/
Karanbir Singh 0b5bb2
echo "Virtual Host Test Page" > /var/www/vhosts/test/index.html
Karanbir Singh 0b5bb2
service httpd restart
Karanbir Singh 0b5bb2
echo -n "HTTPD Virtual Host test:  "
Karanbir Singh 0b5bb2
echo -e "GET / HTTP/1.0\r\n" | nc test 80 | grep 'Virtual Host Test Page' > /dev/null 2>&1
Karanbir Singh 0b5bb2
if [ $? -eq 0 ]; then
Karanbir Singh 0b5bb2
	echo 'PASS'
Karanbir Singh 0b5bb2
else
Karanbir Singh 0b5bb2
	echo 'FAIL'
Karanbir Singh 0b5bb2
    exit 1
Karanbir Singh 0b5bb2
fi