3 # update-ca-certificates
5 # Copyright (c) 2003 Fumitoshi UKAI <ukai@debian.or.jp>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 echo "$0: [--verbose] [--fresh]"
38 CERTSCONF=/etc/ca-certificates.conf
39 CERTSDIR=/usr/share/ca-certificates
40 CERTBUNDLE=ca-certificates.crt
41 ETCCERTSDIR=/etc/ssl/certs
43 if [ "$fresh" = 1 ]; then
44 echo -n "Clearing symlinks in $ETCCERTSDIR..."
45 find . -type l -print | while read symlink
47 case $(readlink $symlink) in
48 $CERTSDIR*) rm -f $symlink;;
51 find . -type l -print | while read symlink
53 test -f $symlink || rm -f $symlink
57 echo -n "Updating certificates in $ETCCERTSDIR...."
59 bundletmp=`mktemp "${CERTBUNDLE}.tmp.XXXXXX"`
60 removed="$(sed -ne 's/^!//p' $CERTSCONF | while read crt
62 if test "$crt" = ""; then continue; fi
63 pem=$(basename "$crt" .crt).pem
64 if test -e "$pem"; then
66 echo "-$ETCCERTSDIR/$pem"
70 added="$(sed -e '/^#/d' -e '/^!/d' $CERTSCONF | while read crt
72 if test "$crt" = ""; then continue; fi
73 if ! test -f "$CERTSDIR/$crt"; then continue; fi
74 pem=$(basename "$crt" .crt).pem
75 if ! test -e "$pem"; then echo "+$ETCCERTSDIR/$pem"; fi
76 ln -sf "$CERTSDIR/$crt" "$pem"
77 cat "$CERTSDIR/$crt" >> "$bundletmp"
79 chmod 0644 "$bundletmp"
80 mv -f "$bundletmp" "$CERTBUNDLE"
82 if [ -n "$added" ] || [ -n "$removed" ]; then
83 # only run if set of files has changed
85 if [ "$verbose" = 0 ]; then
86 c_rehash . > /dev/null 2>&1
92 HOOKSDIR=/etc/ca-certificates/update.d
93 echo -n "Running hooks in $HOOKSDIR...."
95 [ "$verbose" = 0 ] || VERBOSE_ARG=--verbose
96 eval run-parts $VERB_ARG --test -- $HOOKSDIR | while read hook; do
97 printf -- "${removed:+$removed\n}${added:+$added\n}" | eval $hook