#!/bin/bash
# Elevate script
if [ ! "$UID" -eq 0 ]
then
    sudo bash "$BASH_SOURCE" "$USER";
else
    apt install -y p7zip-full libgumbo-dev libexpat1-dev libfuse-dev libssl-dev libcurl4-openssl-dev uuid-dev;
    tempDir="$(mktemp -d)";
    pushd "$tempDir" > /dev/null;

    git clone https://github.com/fangfufu/httpdirfs.git;
    pushd httpdirfs > /dev/null;
    make;
    install -m 755 -D httpdirfs /usr/local/bin/httpdirfs;
    popd > /dev/null;

    git clone https://aur.archlinux.org/ttf-ms-win11-auto.git ttf-win11;
    pushd ttf-win11 > /dev/null;
    # shellcheck source=/dev/null
    source ./PKGBUILD;
    prepare;
    package_ttf-ms-win11-auto;

    rm -f /usr/local/bin/httpdirfs;

    popd > /dev/null;
    wget -O CascadiaCode.zip https://github.com/microsoft/cascadia-code/releases/download/v2111.01/CascadiaCode-2111.01.zip;
    unzip -d . CascadiaCode.zip;
    cp ttf/* /usr/share/fonts/TTF;

    popd > /dev/null;
fi