File: postinst

package info (click to toggle)
chrony 1.21z-5
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 2,080 kB
  • ctags: 2,375
  • sloc: ansic: 14,831; yacc: 858; sh: 588; perl: 426; makefile: 148
file content (93 lines) | stat: -rw-r--r-- 3,272 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh
set -e
# postinst for Chrony John Hasler jhasler@debian.org 2000-2006
# Any possessor of a copy of this program may treat it as if it
# were in the public domain.  I waive all rights.

install-info --quiet --description="Set your clock from the Net" \
	     --section General "General Commands" \
             /usr/share/info/chrony.info

if [ -x /usr/bin/update-menus ] ; then 
    /usr/bin/update-menus 
fi

update-rc.d chrony defaults 83 >/dev/null

cp /usr/share/chrony/chrony.conf /etc/chrony/chrony.conf.new

# Fix up chrony.conf.new.
. /etc/default/rcS

case "$UTC" in
    no|"") echo "# rtconutc" >> /etc/chrony/chrony.conf.new
	MAILUTC="Chrony has been configured to assume that your real-time clock is on local time.
If this is not correct edit /etc/chrony/chrony.conf.  The comments explain
what to do."
	;;
    yes)   echo "rtconutc" >> /etc/chrony/chrony.conf.new
	MAILUTC="Chrony has been configured to assume that your real-time clock is on UTC time.
If this is not correct edit /etc/chrony/chrony.conf.  The comments explain
what to do."
	;;
    *)     echo "# Can't tell how your clock is set: assuming local time." >> /etc/chrony/chrony.conf.new
	MAILUTC="Can't tell how your clock is set: assuming local time.
If this is not correct edit /etc/chrony/chrony.conf.  The comments explain
what to do."
	;;
esac

if [ -z "$2" ] ; then

# As this a new install generate a key.  Remove any keyfile left by a failed install.
    rm -rf /etc/chrony/chrony.keys
    KEYFILE=`tempfile -m 640 -n /etc/chrony/chrony.keys`
    PASSWORD=`head -c 8 /dev/urandom | tr '\0-\377' 'a-zA-Z0-9a-zA-Z0-9a-zA-Z0-9a-zA-Z0-9@@@@####'`
    echo "1 $PASSWORD" > $KEYFILE
    MAILPASSWORD="The password for chronyc is in $KEYFILE."

# And tell root about the key and the rtc setting.    
    if `which /usr/bin/mail > /dev/null`; then
	/usr/bin/mail -s "Chrony" root <<EOF

$MAILPASSWORD

$MAILUTC

In the chrony.conf included in this package:

Chrony has been configured on the assumption that you are using either a dialup
connection or a PPPoE DSL connection.  It will be brought online when PPP 
comes up and offline when it goes down.  If this is not correct you should edit
/etc/chrony/chrony.conf.  The comments explain what to do.  For more 
information on configuring Chrony use the command  'info chrony'.

You can also change the default time servers in  /etc/chrony/chrony.conf.

Updating of the real-time clock has been enabled but some systems that use
either the genrtc driver or have HPET hardware clocks have problems.  To
disable real-time clock updating edit /etc/chrony/chrony.conf.  The
comments explain what to do.

EOF
    fi

else
    
# If we are upgrading from an old version retrieve the files saved by the preinst.
# If we are upgrading from a recent version no need to do anything.
    
    if dpkg --compare-versions "$2" lt-nl 1.21-3 ; then
	if [ -f /etc/chrony/chrony.keys."$2" ]; then
	    mv /etc/chrony/chrony.keys."$2" /etc/chrony/chrony.keys
	fi
	if [ -f /etc/chrony/chrony.conf."$2" ]; then
	    mv /etc/chrony/chrony.conf."$2" /etc/chrony/chrony.conf
	fi
    fi
fi
ucf --sum-file /usr/share/chrony/chrony.conf.md5sum /etc/chrony/chrony.conf.new /etc/chrony/chrony.conf
rm /etc/chrony/chrony.conf.new

invoke-rc.d chrony start
exit 0