#!/bin/bash

glib-compile-schemas /usr/share/glib-2.0/schemas/ || true
mkdir -p /ortak-alan /var/lib/wine-prefix
chmod 1777 /ortak-alan /var/lib/wine-prefix
pam-auth-update --enable etap

if [ -f /ortak-alan/wine/user.reg ] ; then
    sed -i "s/^\"LogPixels\"=dword:000000c0/\"LogPixels\"=dword:00000060/g" /ortak-alan/wine/user.reg
fi

for name in wine64 winefile winecfg wineboot wineserver wine-preloader wine64-preloader; do \
    if [ ! -e /usr/share/etap/bin/$name ] ; then
        ln -s wine /usr/share/etap/bin/$name
    fi
done


if [ "$1" = "configure" ] && [ -n "$2" ] && dpkg --compare-versions "$2" le-nl "2026.07.24"; then
    rm -f /etc/modprobe.d/usbcore.conf || true
    update-initramfs -u -k all || true
fi

# Update the dconf database on first installation or when upgrading from older versions.
if [ "$1" = "configure" ] && { [ -z "$2" ] || dpkg --compare-versions "$2" le-nl "2026.04.14"; }; then
    dconf update || true
fi
