#!/usr/bin/env bash # Install the private Trainlog automatic synchronization user services. set -euo pipefail ROOT="$( CDPATH= cd -- "$(dirname -- "$0")/.." && pwd )" SYNC_ONCE="$ROOT/build/tui/trainlog-sync-once" MTP_ADAPTER="$ROOT/build/tui/trainlog-generation-mtp-adapter" BT_ADAPTER="$ROOT/tools/trainlog_generation_bt_adapter.py" BT_AGENT="$ROOT/tools/trainlog_bt_agent.py" DAEMON="$ROOT/tools/trainlog_syncd.py" GEN_CONFIG="${TRAINLOG_SYNC_GENERATION_CONFIG:-$HOME/.config/trainlog/sync-generation-config-v1.json}" for executable in "$SYNC_ONCE" "$MTP_ADAPTER" "$BT_ADAPTER" "$BT_AGENT" "$DAEMON"; do if [[ ! -x "$executable" ]]; then echo "missing executable: $executable" >&2 echo "run meson compile -C build first and keep Trainlog tools executable" >&2 exit 1 fi done mkdir -p "$HOME/.local/bin" "$HOME/.config/systemd/user" ln -sfn "$SYNC_ONCE" "$HOME/.local/bin/trainlog-sync-once" ln -sfn "$DAEMON" "$HOME/.local/bin/trainlog-syncd" ln -sfn "$BT_AGENT" "$HOME/.local/bin/trainlog-btd" cat > "$HOME/.config/systemd/user/trainlog-syncd.service" < "$HOME/.config/systemd/user/trainlog-btd.service" <