#!/bin/sh

# Add 'main' section if not present
if ! uci get network.config > /dev/null 2>&1; then
    uci add network main
    uci rename network.@main[-1]='config'
    uci set network.config.mode='1'
    uci set network.config.enable_logger='1'
fi

# Add 'internet' section if not present
if ! uci get network.internet > /dev/null 2>&1; then
    uci add network instance
    uci rename network.@instance[-1]='internet'
    uci set network.internet.interval_up='30'
    uci set network.internet.interval_down='30'
    uci set network.internet.mod_user_scripts_initial_delay='300'
    uci set network.internet.mod_user_scripts_sim_preference_mode='sim1only'
    uci set network.internet.mod_user_scripts_single_sim_restart_interval='500'
    uci set network.internet.mod_user_scripts_enabled='0'
    uci set network.internet.enabled='1'
    uci set network.internet.check_type='1'

    # Add hosts
    uci add_list network.internet.hosts='8.8.8.8'
    uci add_list network.internet.hosts='1.1.1.1'
fi

uci commit network

