createWebServer.sh 707 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#!/bin/bash

dir=$(dirname $0)

createRedirect()
{
    while read line
    do
	src=$(echo $line | awk '{print $1}')
	dst=$(echo $line | awk '{print $2}')
	echo create redirect from $src to $dst
	mkdir -p public/$src
	(cat <<EOF
<head>
<title>Page has moved!</title>
<meta http-equiv="Refresh" content="0; URL=$dst" />
</head>

EOF
	) > public/$src/index.html
    done< $dir/redirect.txt
}

updateFileLinks()
{
    for f in $(grep -rsl 'href="/files' public)
    do
	echo update file links in $f
	sed -i 's/href="\/files/href="http:\/\/starpu.gforge.inria.fr\/files/' $f
    done
}

rm -rf public
mkdir public
createRedirect
rsync -az --chmod=ug=rwX,o=rX --exclude .htaccess contents/ public
updateFileLinks