#!/bin/bash

post_install() {
    case "$(uname -m)" in
    aarch64)
        lib_path=/usr/lib/aarch64-linux-gnu/
        ;;
    arm)
        lib_path=/usr/lib/arm-linux-gnueabihf/
        ;;
    esac

    if [ -f /proc/device-tree/compatible ]; then
        comp=$(tr -d '\0' < /proc/device-tree/compatible)
    else
        comp=$(cat /etc/chroot/compatible)
    fi

    cd ${lib_path}
    rm -rf libmali.so*

    case "${comp}" in
    *rk3588*)
        ln -s libmali-valhall-g610-g6p0-wayland.so libmali.so.1.0.0
        ;;
    *rk3568*)
        ln -s libmali-bifrost-g52-g2p0-wayland.so libmali.so.1.0.0
        ;;
    *rk3399*)
        ln -s libmali-midgard-t86x-r18p0-wayland.so libmali.so.1.0.0
        ;;
    *)
        exit 1
    ;;
    esac

    ln -s libmali.so.1.0.0 libmali.so.1
    ln -s libmali.so.1.0.0 libmali.so

    # for user in $(ls /home)
    # do
    #     account_path=/var/lib/AccountsService/users
    #     if [ -d ${accout_path} ]; then
    #         echo "[User]" | tee ${account_path}/${user}
    #         echo "Session=" | tee -a tee ${account_path}/${user}
    #         echo "XSession=ubuntu-wayland" | tee -a tee ${account_path}/${user}
    #         echo "Icon=/home/${user}/.face" | tee -a tee ${account_path}/${user}
    #         echo "SystemAccount=false" | tee -a tee ${account_path}/${user}
    #         echo  | tee -a tee ${account_path}/${user}
    #         echo "[InputSource0]" | tee -a tee ${account_path}/${user}
    #         echo "xkb=us" | tee -a tee ${account_path}/${user}
    #     fi
    # done

    exit 0
}