#!/bin/sh
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# On Debian systems, the full text of the GNU General Public License
# can be found in /usr/share/common-licenses/GPL-3.
#
# Author: Cesare Falco <c.falco@ubuntu.com> - June 2026

mkdir -p "$HOME/.mame"

# Create mame.ini file if not present
if [ ! -f "$HOME/.mame/mame.ini" ]; then
    cp /usr/lib/mame/mame.ini.default "$HOME/.mame/mame.ini"
fi

# Create plugin.ini file if not present
if [ ! -f "$HOME/.mame/plugin.ini" ]; then
    cp /usr/lib/mame/plugin.ini.default "$HOME/.mame/plugin.ini"
fi

# Create ui.ini file if not present
if [ ! -f "$HOME/.mame/ui.ini" ]; then
    cp /usr/lib/mame/ui.ini.default "$HOME/.mame/ui.ini"
fi

exec /usr/lib/mame/mame "$@"
