#!/bin/bash
NEXTCLOUD_DIR="${NEXTCLOUD_DIR}";

# Elevate script
if [ ! "$UID" -eq 0 ]
then
    NEXTCLOUD_DIR="${NEXTCLOUD_DIR}" sudo bash "$BASH_SOURCE" "$USER";
else
    bin=oh-my-posh;
    contextRoot="$(mktemp -d)";
    pushd "$contextRoot" > /dev/null;

    wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O "$bin";
    install "$bin" /usr/local/bin;

    popd > /dev/null;
    rm -rf "$contextRoot";
fi