]>
Commit | Line | Data |
---|---|---|
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 | ||
14 | ongreen=1 | |
ee4fdd07 | 15 | green=$(cat /var/ipfire/ethernet/settings | grep GREEN_NETADDRESS) |
cd1a2927 MT |
16 | if [ -z "$green" ]; then |
17 | : # no Green subnet | |
18 | else | |
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 | |
23 | fi | |
24 | ||
25 | onorange=1 | |
ee4fdd07 | 26 | orange=$(cat /var/ipfire/ethernet/settings | grep ORANGE_NETADDRESS) |
cd1a2927 MT |
27 | if [ -z "$orange" ]; then |
28 | : # no Orange subnet | |
29 | else | |
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 | |
34 | fi | |
35 | ||
36 | # find out language | |
ee4fdd07 | 37 | tlanguage=$(cat /var/ipfire/main/settings | grep LANGUAGE) |
cd1a2927 MT |
38 | tlanguage=${tlanguage##*=} |
39 | ||
40 | if [ -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 | |
66 | else | |
67 | echo Missing parameter | |
68 | fi |