-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_indexes.sh
executable file
·76 lines (73 loc) · 1.97 KB
/
make_indexes.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
70
71
72
73
74
75
76
#!/bin/bash
DETAILS="Built by `whoami` on `hostname -f` at `date -u`"
if test -n "${CIRCLE_BUILD_NUM}" ; then
DETAILS="${DETAILS} (CircleCi ${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME} build ${CIRCLE_BUILD_NUM})"
fi
# Traverse our directory structure...
OLD_DIR=`pwd`;
for DIR in releases libraries ; do
echo ""
echo "Processing directory \"${DIR}\""
echo ""
echo "Deleting files:"
echo ""
find "${DIR}" -type f -name index.html -print -delete
find "${DIR}" -type d -empty -print -delete
echo ""
echo "Creating files:"
echo ""
find "${DIR}" -type d | while read NEW_DIR ; do
echo "${DIR}/${NEW_DIR}"
cd "${NEW_DIR}"
{
echo "<!DOCTYPE html>"
echo "<html>"
echo " <head>"
echo " <title>Index of: ${NEW_DIR}</title>"
echo " </head>"
echo " <body>"
echo " <h1>Index of: ${NEW_DIR}</h1>"
echo " <ul>"
echo " <li class=\"up\"><a href=\"..\">..</a></li>"
for FILE in `ls -1` ; do
if [[ $FILE == "index.html" ]] || [[ $FILE == .* ]] ; then
continue
fi
if test -d "$FILE" ; then
FILE="${FILE}/"
CLASS="dir"
else
CLASS="file"
fi
printf " <li class=\"%s\"><a href=\"%s\">%s</a></li>\n" "${CLASS}" "${FILE}" "${FILE}"
done
echo " </ul>"
echo " <p style=\"font-size: 70%\">${DETAILS}</p>"
echo " </body>"
echo "</html>"
} > index.html
cd "${OLD_DIR}"
done
echo ""
echo "Adding to git:"
echo ""
git add --verbose "${DIR}" || exit 1
done
# Finally create our index...
cat > index.html << EOF
<!DOCTYPE html>
<html>
<head>
<title>Repository Home</title>
</head>
<body>
<h1>Repository Home</h1>
<ul>
<li class="dir"><a href="libraries">libraries/</a></li>
<li class="dir"><a href="releases">releases/</a></li>
</ul>
<p style="font-size: 70%">${DETAILS}</p>
</body>
</html>
EOF
git add --verbose "index.html" || exit 1