#!/bin/bash

kopiaInstall()
{
    if command -v kopia >/dev/null 2>&1; then
        local v
        v=$(kopia --version 2>/dev/null | head -1)
        isNotice "Kopia already installed ($v)"
        return 0
    fi

    isHeader "Installing Kopia backup engine"

    # The privileged download + install runs in the root-owned
    # libreportal-bininstall helper so the manager-run runtime needs no blanket
    # sudo install/tar to /usr/local/bin.
    if runBinInstall install kopia; then
        checkSuccess "Kopia installed to /usr/local/bin/kopia"
        return 0
    fi
    isError "Failed to install Kopia"
    return 1
}
