Skip to content

Instantly share code, notes, and snippets.

@jankatins
Last active July 17, 2018 18:00
Show Gist options
  • Save jankatins/c6854160dd03a3df8b7ff708850854be to your computer and use it in GitHub Desktop.
Save jankatins/c6854160dd03a3df8b7ff708850854be to your computer and use it in GitHub Desktop.
Idea how to make ms odbc deb preinst easier to work with
check_eula_acceptance()
{
    if [ "$ACCEPT_EULA" == "y" ] && [ "$ACCEPT_EULA" == "Y" ]; then
        # to support the old way...
       db_set msodbcsql/accept_eula true
    fi
    db_get msodbcsql/accept_eula || true
    if [ "$RET" != "true" ]; then
        db_set msodbcsql/accept_eula false
        db_fset msodbcsql/accept_eula seen false
        db_input high msodbcsql/accept_eula     || true
        db_go
        db_get msodbcsql/accept_eula
        if [ "$RET" != "true" ]; then
            echo "ERROR: The EULA was not accepted. Installation aborted." >&2
            exit 1
        fi
    fi
}

(untested...)

In salt you could set this by

debconf.set:
  - name: msodbcsql 
  - data: 
    'msodbcsql/accept_eula': {'type': 'string', 'value': 'Y'}
  - require_in:
    - pkg: msodbcsql
@mgkuhn
Copy link

mgkuhn commented Jul 17, 2018

Yes, this would be a huge improvement! Here is another slight improvement of the same idea that also supports using ACCEPT_EULA=n to get the EULA dialogue back, just for completeness:

check_eula_acceptance()
{
    case "$ACCEPT_EULA" in
	[Yy]|[Yy]es|[Tt]rue)
	    db_set msodbcsql/accept_eula true
	    ;;
	[Nn]|[Nn]o|[Ff]alse)
	    db_set msodbcsql/accept_eula false
	    ;;
	'') ;;
	*)
	    echo "ERROR: Unknown value in ACCEPT_EULA, try 'y' or 'n'." >&2
	    exit 1
    esac

    db_get msodbcsql/accept_eula
    if [ "$RET" != "true" ]; then
	db_fset msodbcsql/accept_eula seen false
	db_input high msodbcsql/accept_eula || true
	db_go
	db_get msodbcsql/accept_eula
	if [ "$RET" != "true" ]; then
            echo "ERROR: The EULA was not accepted. Installation aborted." >&2
            exit 1
	fi
    fi
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment