#!/bin/bash

# Install Flatpak and add Flathub remote repository

apt-get -y --autoremove install flatpak

if ! command -v flatpak >/dev/null 2>&1; then
    echo "Failed to install Flatpak"
    exit 1
fi

flatpak remote-add --system --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo

if ! flatpak remotes | grep -q .; then
    echo "Failed to add Flathub remote repository"
    exit 2
fi

exit 0
