-
Notifications
You must be signed in to change notification settings - Fork 27
/
make-redirects.sh
executable file
·69 lines (50 loc) · 1.34 KB
/
make-redirects.sh
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
function makeRedirect() {
echo "Redirects file: $1"
while IFS= read -r line; do
if [[ $line = \#* ]]; then
continue
fi
if [[ -z $line ]]; then
continue
fi
if [[ -z $from_url ]]; then
from_url=$line
continue
fi
if [[ -z $to_url_prefix ]]; then
to_url_prefix=$line
continue
fi
line=${line#./}
from_file=src/site/xdoc/$from_url/${line/.html/.xml}
to_url="${to_url_prefix}/${line}"
echo "process from=$from_file to=$to_url"
if [[ -f $from_file ]]; then
echo "!!! File exist - $from_file not touch"
continue
fi
mkdir -p `dirname $from_file`
cat << EOF > $from_file
<?xml version="1.0"?>
<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
<head>
<title/>
<meta http-equiv="refresh" content="0; URL=https://www.mojohaus.org/$to_url"/>
</head>
<body>
<section name="Site - redirect">
<p>Please go to a new site address
<a href="https://www.mojohaus.org/$to_url">https://www.mojohaus.org/$to_url</a>
</p>
</section>
</body>
</document>
EOF
done < $1
}
cd `dirname $0`
for R in `ls redirects/*.txt`; do
makeRedirect $R
done