#!/usr/bin/env bash

# This script is set to run on login on the OPERATOR machine.
set -euox pipefail

puffin_bin=vehicle/puffin/*AppImage
puffin_launcher=/home/$(whoami)/Desktop/Puffin

# Clean up the old puffin launcher placed during the deprecated auto-
# -update model.
rm --force /home/$(whoami)/Desktop/PUFFIN

# Simple desktop shortcut until we want to build something fancier.
# NOTE(Patrick) - Yes, make a copy and not a symlink. We expect bazel
# to remove this binary when versions change and puffin will likely be
# the one running that process via zstart.
cp --force ${puffin_bin} ${puffin_launcher}

# Replace the current session so that this shell script can be replaced
# in during the build process mentioned above.
exec ${puffin_launcher} ${@}

