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