1 |
#!/bin/sh |
2 |
binrepodir=<%= binrepodir %> |
3 |
uploadinfosdir=<%= uploadinfosdir %> |
4 |
tmpfile=$(mktemp) |
5 |
mail_from="<%= uploadmail_from %>" |
6 |
mail_dest="<%= uploadmail_to %>" |
7 |
|
8 |
test $# = 2 || exit 3 |
9 |
username="$1" |
10 |
comment="$2" |
11 |
|
12 |
/bin/cat > "$tmpfile" |
13 |
sha1sum=$(/usr/bin/sha1sum "$tmpfile" | sed 's/ .*$//') |
14 |
if [ -f "$binrepodir/$sha1sum" ] |
15 |
then |
16 |
echo "File $sha1sum already exists." >&2 |
17 |
/bin/rm -f "$tmpfile" |
18 |
exit 2 |
19 |
fi |
20 |
/bin/mv "$tmpfile" "$binrepodir/$sha1sum" |
21 |
/bin/chmod 644 "$binrepodir/$sha1sum" |
22 |
echo "$username:$comment" > "$uploadinfosdir/$sha1sum" |
23 |
echo "User $username uploaded file $sha1sum: $comment" |
24 |
|
25 |
echo "User $username uploaded file $sha1sum: $comment" | \ |
26 |
/usr/bin/mailx -s "New file uploaded: $sha1sum - $comment" -S "from=$username <$mail_from>" "$mail_dest" |
27 |
|
28 |
exit 0 |
29 |
|