← Back to team overview

sslug-teknik team mailing list archive

Re: Ang Server tid Debian

 

On Wed, 29 Dec 2010 23:33:59 +0100
Phone contacts <tanja@xxxxxxxxxxx> wrote:

> Er prøvet op til flere gange og det resulterer hver gang i den tidsforskel.
> 
Kan nedenstående script ikke løse problemet, er der noget fundamentalt
galt med konfigurationen af uret.

#!/bin/sh
#Set time zone and time
NTP=/var/run/ntpd.pid
NTP_BIN=/etc/init.d/ntp
NTPDATE_BIN=/usr/sbin/ntpdate
AREA=Europe
CITY=Copenhagen
USE_NTP=0

if [ 0 -ne $(id -ru) ]; then
    echo Run as root or use sudo
    exit
fi

if [ -e $NTP ]; then
    echo Terminating running ntp daemon
    PID=$(cat $NTP)
    kill -TERM $PID
    sleep 5
    rm -f $NTP
    USE_NTP=1
fi

echo "tzdata tzdata/Areas select $AREA" | debconf-set-selections
echo "tzdata tzdata/Zones/Europe select $CITY" | debconf-set-selections
TIMEZONE="$AREA/$CITY"
echo $TIMEZONE > /etc/timezone
cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime
if [ -e $NTPDATE_BIN ]; then
	/usr/sbin/ntpdate pool.ntp.org
else
	echo Missing $NTPDATE_BIN: Adjust time manual
fi

if [ $USE_NTP -eq 1 ]; then
	$NTP_BIN start
fi

-- 
Hilsen/Regards
Michael Rasmussen
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE3E80917
A computer is like air conditioning: it becomes useless when you open
windows.



Follow ups

References