#!/bin/bash

resticInstall()
{
    if command -v restic >/dev/null 2>&1; then
        local installed_version
        installed_version=$(restic version 2>/dev/null | head -1 | awk '{print $2}')
        isNotice "restic already installed (version: $installed_version)"
        return 0
    fi

    isHeader "Installing restic"

    # The privileged install (package manager or signed-release download) runs in
    # the root-owned libreportal-bininstall helper so the manager-run runtime
    # needs no blanket sudo apt-get/install.
    if runBinInstall install restic; then
        checkSuccess "restic installed"
        return 0
    fi
    isError "Failed to install restic"
    return 1
}
