#!/bin/bash

# appel en pretemplate pour les conteneurs
# le fichier /etc/timezone est un template EOLE
TIME_ZONE="$(CreoleGet time_zone)"
FILE="/usr/share/zoneinfo/$TIME_ZONE"
if [ -f "$FILE" ]; then
    for group in $(CreoleGet --group)
    do
	if CreoleRun 'test -L /etc/localtime' "${group}"
	then
        CreoleRun "ln -nsf $FILE /etc/localtime" "${group}"
	else
        CreoleRun "cp -f $FILE /etc/localtime" "${group}"
	fi
    done
    if [ -d /var/lib/lxc/addc/rootfs ] && [ "$(CreoleGet ad_local non)" = 'oui' ]; then
        echo "$TIME_ZONE" > /var/lib/lxc/addc/rootfs/etc/timezone
        ln -nsf "$FILE" /var/lib/lxc/addc/rootfs/etc/localtime
    fi
else
    . /usr/lib/eole/ihm.sh
    EchoRouge "Pas de fuseau horaire $TIME_ZONE !"
fi

exit 0
