blob: 30ab53d89875551d818cefeb4f6c7503eede242e (
plain)
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
|
pkgname="atostekid"
# colors
if command -v tput >/dev/null 2>&1; then
all_off="$(tput sgr0)"
bold="${all_off}$(tput bold)"
blue="${bold}$(tput setaf 4)"
red="${bold}$(tput setaf 1)"
yellow="${bold}$(tput setaf 3)"
fi
note() {
printf "${blue-}==>${yellow-} NOTE:${bold-} %s${all_off-}\n" "${1}"
}
warn() {
printf "${red-}==> WARN:${bold-} %s${all_off-}\n" "${1}"
}
is_update_from() {
result="$(vercmp "${1}" "${2}")"
case $result in
'-1'|'0') return 0;;
'1') return 1;;
esac
}
check_pcscd_status() {
if ! systemctl --quiet is-active pcscd.socket 2>/dev/null; then
note "${pkgname} requires that the PC/SC Smart Card Daemon systemd socket (pcscd.socket) is active. Please ensure it is started before launching ${pkgname}."
fi
}
# Remove certs that were installed to system trust store and filesystem in
# previous versions of this package. These are not needed anymore.
deprecate_certificates() {
local legacy_ca_paths=(
"/etc/${pkgname:-atostekid}/scsca.cer"
"/usr/share/${pkgname:-atostekid}/certs/erasmartcard_ehoito_fi_ca.cer"
"/usr/share/${pkgname:-atostekid}/certs/scsca.cer"
)
for legacy_ca_path in "${legacy_ca_paths[@]}"; do
if [[ -f "${legacy_ca_path}" ]]; then
note "Removing trust for legacy CA file ${legacy_ca_path}"
trust anchor --remove "${legacy_ca_path}"
rm "${legacy_ca_path}"
fi
done
local legacy_dirs=(
"/etc/${pkgname:-atostekid}"
"/usr/share/${pkgname:-atostekid}/certs/"
"/usr/share/${pkgname:-atostekid}/"
)
for legacy_dir in "${legacy_dirs[@]}"; do
if [[ -d "${legacy_dir}" ]]; then
rmdir "${legacy_dir}"
fi
done
}
post_install() {
check_pcscd_status
note "Many features of ${pkgname} require user configuration. Please review the official documentation in /usr/share/doc/atostekid/. You may also wish to check the Arch Wiki: https://wiki.archlinux.org/title/Special:Search?search=${pkgname}"
}
post_upgrade() {
new_version="${1}"
old_version="${2}"
if is_update_from "${old_version}" 4.3.1.0-2; then
deprecate_certificates
fi
check_pcscd_status
}
|