#!/bin/bash # # Purpose : Install Supermarket (run by CoreDesktop's `sibling add`). Safe to # run again: it only does what's missing. set -e SELF="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=lib.sh source "$SELF/lib.sh" echo "Installing Supermarket, a marketing suite that runs as a web app on this computer." if ! command -v docker > /dev/null; then echo "Supermarket needs Docker, which CoreDesktop installs. Install it with: sudo pacman -S docker docker-compose" exit 1 fi if ! docker info > /dev/null 2>&1; then if ! id -nG | tr ' ' '\n' | grep -qx docker; then echo "You can't use Docker yet. Add yourself to the docker group, log out and in, and run this again:" echo " sudo usermod -aG docker \$USER" else echo "Docker isn't running. Start it and run this again: sudo systemctl enable --now docker" fi exit 1 fi mkdir -p "$DATA" chmod 700 "$DATA" # The old terminal app's files: copied (never moved) to import/, which the app # reads once on its first start. if [ -f "$OLD_STATE/config.yaml" ] && [ ! -d "$DATA/import" ]; then mkdir -m 700 "$DATA/import" for f in config.yaml state.json posts.json dismissed.json; do [ -f "$OLD_STATE/$f" ] && install -m 600 "$OLD_STATE/$f" "$DATA/import/$f" done echo "Found the old Coremarketing's settings in $OLD_STATE: its inventory, credentials and queued posts will be imported." fi # The token agents use to reach the app. Made here, before the app starts, # so Hermes can be given it. if [ ! -s "$DATA/mcp-token" ]; then (umask 077 && od -An -tx1 -N32 /dev/urandom | tr -d ' \n' > "$DATA/mcp-token" && echo >> "$DATA/mcp-token") fi bash "$SELF/update.sh" if command -v webapp > /dev/null; then if [ ! -f "${XDG_DATA_HOME:-$HOME/.local/share}/applications/webapp-supermarket.desktop" ]; then webapp add Supermarket "$URL" && echo "Added Supermarket to the app grid." fi fi echo bash "$SELF/hermes/setup.sh" || echo "Hermes setup didn't finish; run it again any time: bash $SELF/hermes/setup.sh" if command -v claude > /dev/null && ! claude mcp get supermarket > /dev/null 2>&1; then echo if confirm_yes "Let Claude Code use Supermarket's tools (profile, inventory) too?"; then claude mcp add --transport http --scope user supermarket "$URL/mcp" \ --header "Authorization: Bearer $(tr -d '\n' < "$DATA/mcp-token")" > /dev/null \ && echo "Claude Code can use Supermarket (claude mcp get supermarket)." fi fi echo echo "Supermarket is installed. Open it from the app grid, or at $URL" echo "Start with the company profile, then Settings > AI provider."