diff options
Diffstat (limited to 'debian/openssh-client.preinst')
-rw-r--r-- | debian/openssh-client.preinst | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/debian/openssh-client.preinst b/debian/openssh-client.preinst new file mode 100644 index 000000000..0e200712e --- /dev/null +++ b/debian/openssh-client.preinst | |||
@@ -0,0 +1,30 @@ | |||
1 | #! /bin/sh -e | ||
2 | |||
3 | action="$1" | ||
4 | version="$2" | ||
5 | |||
6 | prepare_transfer_conffile () { | ||
7 | CONFFILE="$1" | ||
8 | [ -e "$CONFFILE" ] || return 0 | ||
9 | |||
10 | md5sum="$(md5sum "$CONFFILE" |sed -e 's/ .*//')" | ||
11 | old_md5sum="$(sed -n -e "/^Conffiles:/,/^[^ ]/{\\' $CONFFILE'{s/^ [^ ]* //;s/ .*//;p}}" /var/lib/dpkg/status)" | ||
12 | if [ "$md5sum" = "$old_md5sum" ]; then | ||
13 | echo >&2 "Transferring ownership of conffile $CONFFILE ..." | ||
14 | mv -f "$CONFFILE" "$CONFFILE.moved-by-preinst" | ||
15 | return 0 | ||
16 | fi | ||
17 | } | ||
18 | |||
19 | case $action in | ||
20 | install|upgrade) | ||
21 | if dpkg --compare-versions "$version" lt 0; then | ||
22 | prepare_transfer_conffile /etc/ssh/moduli | ||
23 | prepare_transfer_conffile /etc/ssh/ssh_config | ||
24 | fi | ||
25 | ;; | ||
26 | esac | ||
27 | |||
28 | #DEBHELPER# | ||
29 | |||
30 | exit 0 | ||