#!/bin/bash

_sys_conf="/etc/os.conf"
_boot_conf="/boot/os.conf"
_conf="/data/etc/os.conf"

if ! [ -f $_conf ]; then
    if [ -f $_boot_conf ]; then
        cp $_boot_conf $_conf
    elif [ -f $_sys_conf ]; then
        cp $_sys_conf $_conf
    fi
fi

source $_conf

has_net_conn() {
    test "$os_networkless" == "true" && return 1

    addr_eth=$(ip addr show dev $os_eth 2>/dev/null | grep inet | tr -s ' ' | sed -r 's/^\s+//' | cut -d ' ' -f 2)
    addr_wlan=$(ip addr show dev $os_wlan 2>/dev/null | grep inet | tr -s ' ' | sed -r 's/^\s+//' | cut -d ' ' -f 2)

    if [ -n "$addr_eth" ] || [ -n "$addr_wlan" ]; then
        return 0
    else
        return 1
    fi
}

