#!/bin/sh

source /etc/utils/shell-utils.sh

TARGET_DESC="NETWORK"

BASEDIR=$(dirname "$0")

echo "[IM][system init][+][${TARGET_DESC}] Start..."

${SPLASH} prg 30
${SPLASH} clear_log
${SPLASH} log "Init networking..."

get_model MODEL_NAME
# get device main MAC address as uppercase string
DEVICE_MAIN_MAC=$($RDIR_APP MACAddress | sed 's/[:]*//g' | tr '[:lower:]' '[:upper:]')

# set hostname according to modelname and MAC address
HOST_NAME="${MODEL_NAME}-${DEVICE_MAIN_MAC}"
log "[+] Set hostname to '$HOST_NAME'"
hostname "$HOST_NAME"

# disable IPv6
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1

${BASEDIR}/rc.network start

${SPLASH} prg 40
${SPLASH} log "DONE."

#ifconfig lo 127.0.0.1


echo "[IM] ifplugd initialization"
/etc/init.d/S82_ifplugd

echo "[IM][system init][+][${TARGET_DESC}] DONE."
