]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> # | |
6 | # # | |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
21 | ||
22 | ongreen=1 | |
23 | green=$(cat /var/ipfire/ethernet/settings | grep GREEN_NETADDRESS) | |
24 | if [ -z "$green" ]; then | |
25 | : # no Green subnet | |
26 | else | |
27 | green=${green##*=}; green="${green%.*}.[0-9]" | |
28 | if [ -n "$(cat /var/ipfire/time/settime.conf | grep $green)" ]; then | |
29 | ongreen=0 # NTP on Green | |
30 | fi | |
31 | fi | |
32 | ||
33 | onorange=1 | |
34 | orange=$(cat /var/ipfire/ethernet/settings | grep ORANGE_NETADDRESS) | |
35 | if [ -z "$orange" ]; then | |
36 | : # no Orange subnet | |
37 | else | |
38 | orange=${orange##*=}; orange="${orange%.*}.[0-9]" | |
39 | if [ -n "$(cat /var/ipfire/time/settime.conf | grep $orange)" ]; then | |
40 | onorange=0 # NTP on Orange | |
41 | fi | |
42 | fi | |
43 | ||
44 | # find out language | |
45 | tlanguage=$(cat /var/ipfire/main/settings | grep LANGUAGE) | |
46 | tlanguage=${tlanguage##*=} | |
47 | ||
48 | if [ -n "$1" ]; then | |
49 | if [ -e /var/ipfire/red/active ] || [ "$ongreen" -eq 0 ] || [ "$onorange" -eq 0 ]; then | |
50 | /usr/bin/ntpdate -su $1 $2 | |
51 | ntpdatetest=$? | |
52 | ||
53 | if [ "$ntpdatetest" -eq 0 ]; then | |
54 | case $tlanguage in | |
55 | en ) date "+%X %Z on %d %B %Y" > /var/lock/time/lastset ; | |
56 | logger -t ipfire "NTP synchronisation event" ;; | |
57 | de ) date "+%X Uhr am %d.%m.%Y" > /var/lock/time/lastset ; | |
58 | logger -t ipfire "NTP Synchronisierung" ;; | |
59 | * ) date "+%X %Z, %Y-%m-%d" > /var/lock/time/lastset ; | |
60 | logger -t ipfire "NTP synchronisation" ;; | |
61 | esac | |
62 | ||
63 | /sbin/hwclock --systohc | |
64 | rm -f /var/lock/time/settimenow | |
65 | # reset counter variable | |
66 | cp /var/ipfire/time/counter.conf /var/lock/time/counter | |
67 | else | |
68 | case $tlanguage in | |
69 | de ) logger -t ipfire "ntpdate fehlerhaft" ;; | |
70 | * ) logger -t ipfire "ntpdate error" ;; | |
71 | esac | |
72 | fi | |
73 | fi | |
74 | else | |
75 | echo Missing parameter | |
76 | fi |