#!/bin/sh # SPDX-License-Identifier: LGPL-3.0-only # SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts® # # Installs nostro for every user of this machine: the system files nostrod needs (its user, its D-Bus and polkit # policies, its systemd unit, the nostro command) and the net.catcrafts.Nostrod Flatpak, system-wide. Run as root. # # install.sh the Flatpaks from the system remote "catcrafts", the Catcrafts Flatpak repository, added with # flatpak remote-add --system --if-not-exists catcrafts https://flatpak.catcrafts.net/catcrafts.flatpakrepo # install.sh --repo DIR the Flatpaks from a local repository, as flatpak-builder --repo=DIR makes one, for testing # install.sh --app the Nostro app too, net.catcrafts.Nostro, for every user (each user can install it for # themselves instead) # # Running it again updates. nostrod's Flatpak was net.catcrafts.Nostro until the app took that id: this moves the state a # nostrod installed under it kept, and removes that Flatpak. It also takes away the activation file of # net.catcrafts.Nostro1.Checkout, a second bus name nostrod had until it lost its checkout over D-Bus: left behind, the # bus would start nostrod for a name nostrod no longer takes. packaging/arch/PKGBUILD installs the same system files # from a package; uninstall.sh removes them. set -eu here=$(cd "$(dirname "$0")" && pwd) repo= app=false while [ $# -gt 0 ]; do case "$1" in --repo) repo=$(cd "${2:?--repo needs a directory}" && pwd); shift 2 ;; --app) app=true; shift ;; *) echo "install.sh: unknown argument '$1'" >&2; exit 2 ;; esac done install -Dm644 "$here/nostro.sysusers" /usr/lib/sysusers.d/nostro.conf systemd-sysusers /usr/lib/sysusers.d/nostro.conf install -Dm644 "$here/net.catcrafts.Nostro1.conf" /usr/share/dbus-1/system.d/net.catcrafts.Nostro1.conf install -Dm644 "$here/net.catcrafts.Nostro1.service" /usr/share/dbus-1/system-services/net.catcrafts.Nostro1.service rm -f /usr/share/dbus-1/system-services/net.catcrafts.Nostro1.Checkout.service install -Dm644 "$here/net.catcrafts.Nostro1.policy" /usr/share/polkit-1/actions/net.catcrafts.Nostro1.policy install -Dm644 "$here/nostrod.service" /etc/systemd/system/nostrod.service install -Dm755 "$here/nostro" /usr/local/bin/nostro systemctl daemon-reload # A nostrod already running keeps the old files until it ends: stop it, and the next call starts the new one. Stopped, it # also leaves its state alone while that moves. systemctl stop nostrod.service # flatpak keeps an app's data under the app's id, so nostrod's state followed the Flatpak's old id. apps=/var/lib/nostro/.var/app if [ -d "$apps/net.catcrafts.Nostro" ]; then if [ -e "$apps/net.catcrafts.Nostrod" ]; then echo "install.sh: both $apps/net.catcrafts.Nostro and $apps/net.catcrafts.Nostrod exist; keep the one that holds the bank connections as net.catcrafts.Nostrod, remove the other, and run this again" >&2 exit 1 fi mv "$apps/net.catcrafts.Nostro" "$apps/net.catcrafts.Nostrod" echo "moved nostrod's state from $apps/net.catcrafts.Nostro to $apps/net.catcrafts.Nostrod" fi # The app's Flatpak runs nostro-app; the old nostrod Flatpak ran nostro. if flatpak info --system --show-metadata net.catcrafts.Nostro 2>/dev/null | grep -qx 'command=nostro'; then flatpak uninstall --system -y --noninteractive net.catcrafts.Nostro fi remote=catcrafts if [ -n "$repo" ]; then # A local repository is unsigned: for a build of your own, never for one from elsewhere. The remote may be left from # an earlier run with another directory. remote=nostro-local flatpak remote-add --system --if-not-exists --no-gpg-verify nostro-local "file://$repo" flatpak remote-modify --system --no-gpg-verify --url="file://$repo" nostro-local fi flatpak install --system -y --noninteractive --or-update "$remote" net.catcrafts.Nostrod//stable if [ "$app" = true ]; then flatpak install --system -y --noninteractive --or-update "$remote" net.catcrafts.Nostro//stable fi busctl call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus ReloadConfig echo "nostro is installed: nostrod starts with the first call, such as 'nostro connectors add bunq'"