#!/bin/sh
# The executable needs to be run from its data directory, and needs to store
# configuration in it. We therefore mirror the data directory hierarchy in
# ~/.flare, and create symlinks to the data files.
if [ -d ~/.flare ]
then
echo "Using existing ~/.flare directory."
else
echo "Creating ~/.flare directory."
cd %%DATADIR%% || exit 1
find . -type d \! \( -name config \) -exec mkdir -p ~/.flare/{} \;
find * -type f -exec ln -s %%DATADIR%%/{} ~/.flare/{} \; 2>/dev/null
mkdir ~/.flare/config ~/.flare/saves
cp -f %%DATADIR%%/config/keybindings.txt ~/.flare/config/
cp -f %%DATADIR%%/config/settings.txt ~/.flare/config/
chmod 640 ~/.flare/config/keybindings.txt ~/.flare/config/settings.txt
fi
cd ~/.flare || exit 1
echo "Loading..."
exec %%DATADIR%%/flare "$@"