#!/bin/bash
#
# Initial script for Live operating system
# This script are launching before starting init from linux-live script.
# Current dir allways must be set to root (/)
# All system path must be relative, except initrd dirs

ENABLED=yes
[ "$ENABLED" != "yes" ] && exit 0

NTPSERVERS="ntp1.vniiftri.ru,ntp2.vniiftri.ru,ntp3.vniiftri.ru,ntp4.vniiftri.ru,ntp21.vniiftri.ru,ru.pool.ntp.org"

PATH=.:/:/usr/bin:/usr/local/bin:/usr/local/sbin
DEBUGMODE=no
. usr/lib/ublinux/functions
. usr/lib/ublinux/os-config
debug_mode "$0" "$@"

echo $SYSCONF | grep -q ^/ && SYSCONF=.$SYSCONF
[ -f $SYSCONF/config ] && . $SYSCONF/config

if  [ ! -z "$NTPSERVERS" ]; then 
    if [ "$NTPSERVERS" == "dhcp" ]; then
	sed -i 's/NTP_SERVERS=.*/NTP_SERVERS=$DHCP4_NTP_SERVERS/' etc/NetworkManager/dispatcher.d/10-update-timesyncd
    else
	sed -i "s/NTP_SERVERS=.*/NTP_SERVERS=\"$(echo $NTPSERVERS | tr ',;' ' ')\"/" etc/NetworkManager/dispatcher.d/10-update-timesyncd
    fi
fi
