You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

multisign.sh 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #! /bin/sh
  2. #
  3. # Licensed to the Apache Software Foundation (ASF) under one or more
  4. # contributor license agreements. See the NOTICE file distributed with
  5. # this work for additional information regarding copyright ownership.
  6. # The ASF licenses this file to You under the Apache License, Version 2.0
  7. # (the "License"); you may not use this file except in compliance with
  8. # the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. #
  18. # create md5 checksums and gpg signatures
  19. echo "If you use gpg2 you need to set GPG_BIN accordingly"
  20. GPG_BIN=gpg
  21. stty -echo
  22. echo "enter your GPG passphrase"
  23. read passphrase
  24. stty echo
  25. # Do we have md5sum and sha1sum?
  26. # (We can use openssl if not, but the files it produces aren't as nice)
  27. which md5sum > /dev/null
  28. LACKING_MD5SUM=$?
  29. which sha1sum > /dev/null
  30. LACKING_SHA1SUM=$?
  31. for i in *; do
  32. echo ""
  33. echo Signing $i
  34. echo $passphrase | $GPG_BIN --passphrase-fd 0 --output $i.asc --detach-sig --armor $i
  35. $GPG_BIN --verify $i.asc $i
  36. echo Hashing $i
  37. if [ "$LACKING_MD5SUM" = "1" ]; then
  38. openssl md5 < $i > $i.md5
  39. else
  40. md5sum $i > $i.md5
  41. fi
  42. if [ "$LACKING_SHA1SUM" = "1" ]; then
  43. openssl sha1 < $i > $i.sha1
  44. else
  45. sha1sum $i > $i.sha1
  46. fi
  47. done