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