#!/bin/sh
# If we're running in-situ on a live router, we don't want to wait around
# for uci-defaults/99-speedify-networking to be applied. They are executed as
# part of the boot process.
# Instead, we can simply run it ourselves.
# Detecting if /etc/uci-defaults/99-speedify-networking exists should be sufficient
# to infer whether or not we're running in-situ on a live device, or in an image
# builder or similar build system. UCI-defaults files should be deleted after they
# are executed during boot.
set -e
if [ -f /etc/uci-defaults/99-speedify-networking ]
then
  sh /etc/uci-defaults/99-speedify-networking
  rm /etc/uci-defaults/99-speedify-networking
fi

# if running on openwrt with apk, we need to restart services after install
if command -v apk >/dev/null 2>&1
then
  /etc/init.d/speedify enable || true
  /etc/init.d/speedify restart || true
fi