2004-08-09 03:23:20 +09:00
|
|
|
#!/bin/sh -e
|
2003-10-07 03:06:06 +09:00
|
|
|
#
|
|
|
|
# update-ca-certificates
|
|
|
|
#
|
|
|
|
# Copyright (c) 2003 Fumitoshi UKAI <ukai@debian.or.jp>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
|
|
|
verbose=0
|
|
|
|
fresh=0
|
|
|
|
while [ $# -gt 0 ];
|
|
|
|
do
|
|
|
|
case $1 in
|
|
|
|
--verbose|-v)
|
|
|
|
verbose=1;;
|
|
|
|
--fresh|-f)
|
|
|
|
fresh=1;;
|
|
|
|
--help|-h|*)
|
|
|
|
echo "$0: [--verbose] [--fresh]"
|
|
|
|
exit;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
CERTSCONF=/etc/ca-certificates.conf
|
|
|
|
CERTSDIR=/usr/share/ca-certificates
|
2005-05-18 00:40:54 +09:00
|
|
|
CERTBUNDLE=ca-certificates.crt
|
2008-08-09 14:58:24 -03:00
|
|
|
ETCCERTSDIR=/etc/ssl/certs
|
|
|
|
cd $ETCCERTSDIR
|
2003-10-07 03:06:06 +09:00
|
|
|
if [ "$fresh" = 1 ]; then
|
2008-08-09 14:58:24 -03:00
|
|
|
echo -n "Clearing symlinks in $ETCCERTSDIR..."
|
2006-10-28 02:28:50 +09:00
|
|
|
find . -type l -print | while read symlink
|
|
|
|
do
|
|
|
|
case $(readlink $symlink) in
|
|
|
|
$CERTSDIR*) rm -f $symlink;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
find . -type l -print | while read symlink
|
|
|
|
do
|
|
|
|
test -f $symlink || rm -f $symlink
|
|
|
|
done
|
2003-10-07 03:06:06 +09:00
|
|
|
echo "done."
|
|
|
|
fi
|
2008-08-09 14:58:24 -03:00
|
|
|
echo -n "Updating certificates in $ETCCERTSDIR...."
|
2003-10-07 03:06:06 +09:00
|
|
|
|
2005-05-18 00:40:54 +09:00
|
|
|
bundletmp=`mktemp "${CERTBUNDLE}.tmp.XXXXXX"`
|
2008-08-09 14:58:24 -03:00
|
|
|
removed="$(sed -ne 's/^!//p' $CERTSCONF | while read crt
|
2003-10-07 03:06:06 +09:00
|
|
|
do
|
2004-08-09 03:23:20 +09:00
|
|
|
if test "$crt" = ""; then continue; fi
|
|
|
|
pem=$(basename "$crt" .crt).pem
|
2008-08-09 14:58:24 -03:00
|
|
|
if test -e "$pem"; then
|
|
|
|
rm -f "$pem"
|
|
|
|
echo "-$ETCCERTSDIR/$pem"
|
|
|
|
fi
|
|
|
|
done)"
|
2003-10-07 03:06:06 +09:00
|
|
|
|
2008-08-09 14:58:24 -03:00
|
|
|
added="$(sed -e '/^#/d' -e '/^!/d' $CERTSCONF | while read crt
|
2003-10-07 03:06:06 +09:00
|
|
|
do
|
2004-08-09 03:23:20 +09:00
|
|
|
if test "$crt" = ""; then continue; fi
|
|
|
|
if ! test -f "$CERTSDIR/$crt"; then continue; fi
|
2003-10-07 03:06:06 +09:00
|
|
|
pem=$(basename "$crt" .crt).pem
|
2008-08-09 14:58:24 -03:00
|
|
|
if ! test -e "$pem"; then echo "+$ETCCERTSDIR/$pem"; fi
|
2003-10-07 03:06:06 +09:00
|
|
|
ln -sf "$CERTSDIR/$crt" "$pem"
|
2005-05-18 00:40:54 +09:00
|
|
|
cat "$CERTSDIR/$crt" >> "$bundletmp"
|
2008-08-09 14:58:24 -03:00
|
|
|
done)"
|
2005-05-18 00:40:54 +09:00
|
|
|
chmod 0644 "$bundletmp"
|
|
|
|
mv -f "$bundletmp" "$CERTBUNDLE"
|
|
|
|
|
2008-08-09 14:58:24 -03:00
|
|
|
if [ -n "$added" ] || [ -n "$removed" ]; then
|
|
|
|
# only run if set of files has changed
|
|
|
|
|
|
|
|
if [ "$verbose" = 0 ]; then
|
|
|
|
c_rehash . > /dev/null 2>&1
|
|
|
|
else
|
|
|
|
c_rehash .
|
|
|
|
fi
|
|
|
|
echo "done."
|
|
|
|
|
|
|
|
HOOKSDIR=/etc/ca-certificates/update.d
|
|
|
|
echo -n "Running hooks in $HOOKSDIR...."
|
|
|
|
VERBOSE_ARG=
|
|
|
|
[ "$verbose" = 0 ] || VERBOSE_ARG=--verbose
|
|
|
|
eval run-parts $VERB_ARG --test -- $HOOKSDIR | while read hook; do
|
|
|
|
printf -- "${removed:+$removed\n}${added:+$added\n}" | eval $hook
|
|
|
|
done
|
|
|
|
echo "done."
|
2003-10-07 03:06:06 +09:00
|
|
|
else
|
2008-08-09 14:58:24 -03:00
|
|
|
echo "done."
|
2003-10-07 03:06:06 +09:00
|
|
|
fi
|