-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·75 lines (69 loc) · 1.92 KB
/
update.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
#!/bin/bash
root=http://rjmac.github.com
if [ "x$1" = "x-go" ]; then
dir="$2"
cd "$dir"
cat >index.html <<EOF
<html>
<head>
<title>Index of /$dir/</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<h1>Index of /$dir/</h1>
<table cellspacing="10">
<tr>
<th align="left">Name</th>
<th>Last Modified</th>
<th>Size</th>
<th>Description</th>
</tr>
<tr>
<td>
<a href="../">Parent Directory</a>
</td>
</tr>
EOF
for f in *; do
if [ "$f" != "index.html" ]; then
if [ -d "$f" ]; then
link="$root/$dir/$f/"
size=" "
else
link="$root/$dir/$f"
size=$(/usr/bin/stat -c %s "$f")
fi
lastmodified_epoch=$(/usr/bin/stat -c %Y "$f")
lastmodified=$(perl -e 'use POSIX; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime('$lastmodified_epoch'); print strftime("%a %b %d %H:%M:%S GMT %Y", $sec,$min,$hour,$mday,$mon,$year);')
cat >>index.html <<EOF
<tr>
<td>
<a href="$link">$f</a>
</td>
<td>
$lastmodified
</td>
<td align="right">
$size
</td>
<td>
</td>
</tr>
EOF
fi
done
cat >>index.html <<EOF
</table>
</body>
</html>
EOF
else
# rsync --progress -ra rojoma.com:nexus/sonatype-work/nexus/storage/ maven
find maven -name repository-metadata.xml -print0 | xargs -0 sed -i "s!@rootUrl@/content/repositories/!$root/maven/!"
echo Regenerating index.html...
find maven -type d -exec "$0" -go '{}' \;
git add .
GIT_EDITOR=/bin/true git commit --amend
git push -f
fi