Blame SOURCES/ca-legacy

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