]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/scripts/settime
CGI fuer DHCP gefixt und if Skripte zurueckgesetzt
[people/pmueller/ipfire-2.x.git] / src / scripts / settime
CommitLineData
cd1a2927
MT
1#!/bin/sh
2#
3# IPCop CGIs
4#
5# This file is part of the IPCop Project
6#
7# This code is distributed under the terms of the GPL
8#
9# (c) Eric Oberlander June 2002
10# (c) Eric Oberlander December 2002 - internationalisation added
11#
12# /usr/local/bin/settime
13
14ongreen=1
ee4fdd07 15green=$(cat /var/ipfire/ethernet/settings | grep GREEN_NETADDRESS)
cd1a2927
MT
16if [ -z "$green" ]; then
17 : # no Green subnet
18else
19 green=${green##*=}; green="${green%.*}.[0-9]"
ee4fdd07 20 if [ -n "$(cat /var/ipfire/time/settime.conf | grep $green)" ]; then
cd1a2927
MT
21 ongreen=0 # NTP on Green
22 fi
23fi
24
25onorange=1
ee4fdd07 26orange=$(cat /var/ipfire/ethernet/settings | grep ORANGE_NETADDRESS)
cd1a2927
MT
27if [ -z "$orange" ]; then
28 : # no Orange subnet
29else
30 orange=${orange##*=}; orange="${orange%.*}.[0-9]"
ee4fdd07 31 if [ -n "$(cat /var/ipfire/time/settime.conf | grep $orange)" ]; then
cd1a2927
MT
32 onorange=0 # NTP on Orange
33 fi
34fi
35
36# find out language
ee4fdd07 37tlanguage=$(cat /var/ipfire/main/settings | grep LANGUAGE)
cd1a2927
MT
38tlanguage=${tlanguage##*=}
39
40if [ -n "$1" ]; then
ee4fdd07 41 if [ -e /var/ipfire/red/active ] || [ "$ongreen" -eq 0 ] || [ "$onorange" -eq 0 ]; then
cd1a2927
MT
42 /usr/bin/ntpdate -su $1 $2
43 ntpdatetest=$?
44
45 if [ "$ntpdatetest" -eq 0 ]; then
46 case $tlanguage in
ee4fdd07 47 en ) date "+%X %Z on %d %B %Y" > /var/ipfire/time/lastset ;
4ed2816f 48 logger -t ipfire "NTP synchronisation event" ;;
ee4fdd07 49 de ) date "+%X Uhr am %d.%m.%Y" > /var/ipfire/time/lastset ;
4ed2816f 50 logger -t ipfire "NTP Synchronisierung" ;;
ee4fdd07 51 * ) date "+%X %Z, %Y-%m-%d" > /var/ipfire/time/lastset ;
4ed2816f 52 logger -t ipfire "NTP synchronisation" ;;
cd1a2927
MT
53 esac
54
55 /sbin/hwclock --systohc
ee4fdd07 56 rm -f /var/ipfire/time/settimenow
cd1a2927 57 # reset counter variable
ee4fdd07 58 cp /var/ipfire/time/counter.conf /var/ipfire/time/counter
cd1a2927
MT
59 else
60 case $tlanguage in
4ed2816f 61 de ) logger -t ipfire "ntpdate fehlerhaft" ;;
4ed2816f 62 * ) logger -t ipfire "ntpdate error" ;;
cd1a2927
MT
63 esac
64 fi
65 fi
66else
67 echo Missing parameter
68fi