Blame SOURCES/ca-legacy

3c42f9
#!/bin/sh
3c42f9
3c42f9
#set -vx
3c42f9
3c42f9
LCFILE=/etc/pki/ca-trust/ca-legacy.conf
3c42f9
LLINK=/etc/pki/ca-trust/source/ca-bundle.legacy.crt
3c42f9
LDEFAULT=/usr/share/pki/ca-trust-legacy/ca-bundle.legacy.default.crt
3c42f9
LDISABLE=/usr/share/pki/ca-trust-legacy/ca-bundle.legacy.disable.crt
3c42f9
3c42f9
# An absent value, or any unexpected value, is treated as "default".
3c42f9
is_disabled()
3c42f9
{
3c42f9
    grep -i "^legacy *= *disable *$" $LCFILE >/dev/null 2>&1
3c42f9
}
3c42f9
3c42f9
do_check()
3c42f9
{
3c42f9
    is_disabled
3c42f9
    if [ $? -eq 0 ]; then
3c42f9
        echo "Legacy CAs are set to DISABLED in file $LCFILE (affects install/upgrade)"
3c42f9
        LEXPECT=$LDISABLE
3c42f9
    else
3c42f9
        echo "Legacy CAs are set to DEFAULT in file $LCFILE (affects install/upgrade)"
3c42f9
        LEXPECT=$LDEFAULT
3c42f9
    fi
3c42f9
    echo "Status of symbolic link $LLINK:"
3c42f9
    readlink -v $LLINK
3c42f9
}
3c42f9
3c42f9
do_install()
3c42f9
{
3c42f9
    is_disabled
3c42f9
    if [ $? -eq 0 ]; then
3c42f9
        # found, legacy is disabled
3c42f9
        ln -sf $LDISABLE $LLINK
3c42f9
    else
3c42f9
        # expression not found, legacy is set to default
3c42f9
        ln -sf $LDEFAULT $LLINK
3c42f9
    fi
3c42f9
}
3c42f9
3c42f9
do_default()
3c42f9
{
3c42f9
    sed -i 's/^legacy *=.*$/legacy=default/' $LCFILE
3c42f9
    do_install
3c42f9
    /usr/bin/update-ca-trust
3c42f9
}
3c42f9
3c42f9
do_disable()
3c42f9
{
3c42f9
    sed -i 's/^legacy *=.*$/legacy=disable/' $LCFILE
3c42f9
    do_install
3c42f9
    /usr/bin/update-ca-trust
3c42f9
}
3c42f9
3c42f9
do_help()
3c42f9
{
3c42f9
    echo "usage: $0 [check | default | disable | install]"
3c42f9
}
3c42f9
3c42f9
if [[ $# -eq 0 ]]; then
3c42f9
  # no parameters
3c42f9
  do_help
3c42f9
  exit $?
3c42f9
fi
3c42f9
3c42f9
if [[ "$1" = "install" ]]; then
3c42f9
  do_install
3c42f9
  exit $?
3c42f9
fi
3c42f9
3c42f9
if [[ "$1" = "default" ]]; then
3c42f9
  do_default
3c42f9
  exit $?
3c42f9
fi
3c42f9
if [[ "$1" = "disable" ]]; then
3c42f9
  do_disable
3c42f9
  exit $?
3c42f9
fi
3c42f9
3c42f9
if [[ "$1" = "check" ]]; then
3c42f9
  do_check
3c42f9
  exit $?
3c42f9
fi
3c42f9
3c42f9
echo "$0: Unsupported command $1"
3c42f9
do_help