#!/bin/bash
# Elevate script
if [ ! "$UID" -eq 0 ]
then
    sudo bash "$BASH_SOURCE" "$USER";
else
    homeDir="$(sudo -u "$1" bash -c 'realpath ~')";
    fontFileBaseName="Caskaydia Cove Regular Nerd Font Complete.otf";
    tempFile="$(sudo -u "$1" mktemp -d)/$fontFileBaseName";
    destination=/usr/share/font/opentype;

    sudo -u "$1" cp "$homeDir/Nextcloud/Caskaydia Cove Regular Nerd Font Complete.otf" "$tempFile";
    cp "$tempFile" /usr/share/fonts/opentype;
fi