#!/bin/sh

# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2016 Team LibreELEC (https://libreelec.tv)

. /etc/profile

oe_setup_addon service.hyperion

if [ ! -f "$ADDON_HOME/hyperion.config.json" ]; then
  mkdir -p $ADDON_HOME
  cp $ADDON_DIR/config/hyperion.config.json.sample $ADDON_HOME/hyperion.config.json
fi

exec hyperiond $ADDON_HOME/hyperion.config.json &
echo $! > /run/hyperiond.pid

if [ -f "/usr/bin/Xorg" ]; then
  exec hyperion-x11 &
fi
