home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / sbin / update-ca-certificates < prev    next >
Encoding:
Text File  |  2006-11-08  |  2.1 KB  |  84 lines

  1. #!/bin/sh -e
  2. #
  3. # update-ca-certificates
  4. #
  5. # Copyright (c) 2003 Fumitoshi UKAI <ukai@debian.or.jp>
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19. #
  20.  
  21. verbose=0
  22. fresh=0
  23. while [ $# -gt 0 ];
  24. do
  25.   case $1 in
  26.   --verbose|-v)
  27.       verbose=1;;
  28.   --fresh|-f)
  29.     fresh=1;;
  30.   --help|-h|*)
  31.     echo "$0: [--verbose] [--fresh]"
  32.     exit;;
  33.   esac
  34.   shift
  35. done
  36.  
  37. CERTSCONF=/etc/ca-certificates.conf
  38. CERTSDIR=/usr/share/ca-certificates
  39. CERTBUNDLE=ca-certificates.crt
  40. cd /etc/ssl/certs
  41. if [ "$fresh" = 1 ]; then
  42.   echo -n "Clearing symlinks in /etc/ssl/certs..."
  43.   find . -type l -print | while read symlink
  44.   do
  45.      case $(readlink $symlink) in
  46.      $CERTSDIR*) rm -f $symlink;;
  47.      esac
  48.   done
  49.   find . -type l -print | while read symlink
  50.   do
  51.      test -f $symlink || rm -f $symlink
  52.   done
  53.   echo "done."
  54. fi
  55. echo -n "Updating certificates in /etc/ssl/certs...."
  56.  
  57. bundletmp=`mktemp "${CERTBUNDLE}.tmp.XXXXXX"`
  58. sed -ne 's/^!//p' $CERTSCONF | while read crt
  59. do
  60.  if test "$crt" = ""; then continue; fi
  61.  pem=$(basename "$crt" .crt).pem
  62.  if test -e "$pem"; then rm -f "$pem"; fi
  63. done
  64.  
  65. sed -e '/^#/d' -e '/^!/d' $CERTSCONF | while read crt
  66. do
  67.  if test "$crt" = ""; then continue; fi
  68.  if ! test -f "$CERTSDIR/$crt"; then continue; fi
  69.  pem=$(basename "$crt" .crt).pem
  70.  ln -sf "$CERTSDIR/$crt" "$pem"
  71.  cat "$CERTSDIR/$crt" >> "$bundletmp"
  72. done
  73. chmod 0644 "$bundletmp"
  74. mv -f "$bundletmp" "$CERTBUNDLE"
  75.  
  76. if [ "$verbose" = 0 ]; then
  77.   c_rehash . > /dev/null 2>&1
  78. else
  79.   c_rehash .
  80. fi
  81. echo "done."
  82.  
  83.