]> git.ipfire.org Git - people/mfischer/ipfire-2.x.git/blob - src/scripts/settime
Update:
[people/mfischer/ipfire-2.x.git] / src / scripts / settime
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
14 ongreen=1
15 green=$(cat /var/ipfire/ethernet/settings | grep GREEN_NETADDRESS)
16 if [ -z "$green" ]; then
17 : # no Green subnet
18 else
19 green=${green##*=}; green="${green%.*}.[0-9]"
20 if [ -n "$(cat /var/ipfire/time/settime.conf | grep $green)" ]; then
21 ongreen=0 # NTP on Green
22 fi
23 fi
24
25 onorange=1
26 orange=$(cat /var/ipfire/ethernet/settings | grep ORANGE_NETADDRESS)
27 if [ -z "$orange" ]; then
28 : # no Orange subnet
29 else
30 orange=${orange##*=}; orange="${orange%.*}.[0-9]"
31 if [ -n "$(cat /var/ipfire/time/settime.conf | grep $orange)" ]; then
32 onorange=0 # NTP on Orange
33 fi
34 fi
35
36 # find out language
37 tlanguage=$(cat /var/ipfire/main/settings | grep LANGUAGE)
38 tlanguage=${tlanguage##*=}
39
40 if [ -n "$1" ]; then
41 if [ -e /var/ipfire/red/active ] || [ "$ongreen" -eq 0 ] || [ "$onorange" -eq 0 ]; then
42 /usr/bin/ntpdate -su $1 $2
43 ntpdatetest=$?
44
45 if [ "$ntpdatetest" -eq 0 ]; then
46 case $tlanguage in
47 en ) date "+%X %Z on %d %B %Y" > /var/ipfire/time/lastset ;
48 logger -t ipfire "NTP synchronisation event" ;;
49 da ) date "+%k:%M:%S på %d/%m/%y" > /var/ipfire/time/lastset ;
50 logger -t ipfire "NTP synkronisering" ;;
51 de ) date "+%X Uhr am %d.%m.%Y" > /var/ipfire/time/lastset ;
52 logger -t ipfire "NTP Synchronisierung" ;;
53 fr ) date "+%X le %e/%m/%y" > /var/ipfire/time/lastset ;
54 logger -t ipfire "synchronisation NTP" ;;
55 it ) date "+%X il %d-%m-%Y" > /var/ipfire/time/lastset ;
56 logger -t ipfire "sincronizzazione NTP" ;;
57 nl ) date "+%X %e-%m-%Y" > /var/ipfire/time/lastset ;
58 logger -t ipfire "NTP synchronisatie" ;;
59 no ) date "+%X på %d-%m-%y" > /var/ipfire/time/lastset ;
60 logger -t ipfire "NTP synkronisering" ;;
61 sv ) date "+%H.%M.%S på %y-%m-%d" > /var/ipfire/time/lastset ;
62 logger -t ipfire "NTP synkronisering" ;;
63 es ) date "+%X %e/%-m/%y" > /var/ipfire/time/lastset ;
64 logger -t ipfire "NTP sincronizado" ;;
65 * ) date "+%X %Z, %Y-%m-%d" > /var/ipfire/time/lastset ;
66 logger -t ipfire "NTP synchronisation" ;;
67 esac
68
69 /sbin/hwclock --systohc
70 rm -f /var/ipfire/time/settimenow
71 # reset counter variable
72 cp /var/ipfire/time/counter.conf /var/ipfire/time/counter
73 else
74 case $tlanguage in
75 de ) logger -t ipfire "ntpdate fehlerhaft" ;;
76 fr ) logger -t ipfire "ntpdate erreur" ;;
77 it ) logger -t ipfire "ntpdate errato" ;;
78 * ) logger -t ipfire "ntpdate error" ;;
79 esac
80 fi
81 fi
82 else
83 echo Missing parameter
84 fi