File: ferm.preinst

package info (click to toggle)
ferm 2.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,140 kB
  • sloc: perl: 2,839; sh: 126; makefile: 120
file content (37 lines) | stat: -rw-r--r-- 1,240 bytes parent folder | download
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
#!/bin/sh
set -e

action=$1
version=$2

DEFAULTSFILE="/etc/default/ferm"
BACKUPDEFAULTSFILE="${DEFAULTSFILE}.bak"
# sha256 hashes of $DEFAULTSFILE in ferm 2.5.1-4,↲
# with ENABLE="yes" and ENABLE="no"↲
DEFAULTSFILEHASHES="
64c84ccb16e984935c05dec6fa8d6b424b4f83735a9c53430a4ba34c5eb3074d
96affdfb381229de75cacb94412580df3938ad5f1e87ae1d004ab303630cd571
"

if [ "${action}" = "upgrade" ]; then
    # remove old cache files
    rm -f /var/cache/ferm/*.sh /var/cache/ferm/*.tmp

    # ferm 2.5.1-4 and earlier managed their defaultsfile in the
    # maintainer script. Move old defaultsfile away if unchanged
    if dpkg --compare-versions "${version}" le-nl "2.5.1-4"; then
        if [ -e "${DEFAULTSFILE}" ]; then
            CURRENT_HASH="$(sha256sum "${DEFAULTSFILE}" | cut -d ' ' -f 1)"
	    if printf "%s\n" "${DEFAULTSFILEHASHES}" | grep --quiet --line-regexp --fixed-strings "${CURRENT_HASH}"; then
                if [ -e "${BACKUPDEFAULTSFILE}" ]; then
                    TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
                    mv "${BACKUPDEFAULTSFILE}" "${BACKUPDEFAULTSFILE}.${TIMESTAMP}"
                fi
                mv "${DEFAULTSFILE}" "${DEFAULTSFILE}.bak"
            fi
        fi
    fi
fi


#DEBHELPER#