#!/bin/sh
# load common functions
. /opt/lnxall_app/lib/dyiot/scripts/init-functions.sh

lnxdf_systemd_disable strongswan hostapd avahi-daemon avahi-daemon.socket ModemManager
systemctl disable location_4g.service >/dev/null 2>/dev/null

lnxdf_factory_inst
lnxdf_bdhcpd_inst
lnxdf_etcconfig_inst

# initialize network and wireless configuration
lnxdf_wifi_inst
NETDEVS="$(findrealnet 2>/dev/null)"
if [ "${NETDEVS}" = "enp5s0 enp6s0 enp7s0 enp8s0" ] ; then
	if [ ! -f /etc/config/network ] ; then
		rm -rf /etc/config/network
		cp -v -f /opt/lnxall_app/platspec/etc-config-network-5678 /etc/config/network
	fi
elif [ "${NETDEVS}" = "enp1s0 enp2s0 enp3s0 enp4s0" ] ; then
	if [ ! -f /etc/config/network ] ; then
		rm -rf /etc/config/network
		cp -v -f /opt/lnxall_app/platspec/etc-config-network-1234 /etc/config/network
	fi
else
	lnxdf_network_inst
fi

nothup sh -c "sleep 1 ; netuci"
exit 0
