blob: 955b58a550956364992df8c9dc6d974ad36c5f3b (
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
76
77
78
|
basename=eng-nld
pkgname=dict-freedict-$basename
dictd_conf=/etc/dict/dictd.conf
datadir=/usr/share/dictd
conf="database $basename {
data $datadir/$basename.dict.dz
index $datadir/$basename.index
}"
post_install()
{
echo
if pacman -Qq dictd > /dev/null 2>&1
then
if grep -q "^database *$basename" "$dictd_conf"
then
echo "$pkgname already configured in $dictd_conf"
else
echo "Adding configuration for $pkgname to $dictd_conf"
echo "$conf" >> "$dictd_conf"
fi
if systemctl -q is-active dictd.service
then
echo "Restarting dictd service in order to" \
"use the new dictionary database"
systemctl restart dictd.service
else
echo "Starting dictd service in order to" \
"use the new dictionary database"
systemctl start dictd.service
fi
else
echo "dictd does not appear to be installed."
echo "In order to use this database you should either" \
"install dictd or alternatively" \
"another dict server and configure it on your own."
fi
echo
}
post_upgrade()
{
if pacman -Qq dictd > /dev/null 2>&1 && \
systemctl -q is-active dictd.service
then
echo -e "\nRestarting dictd service in order to" \
"use the updated dictionary database"
systemctl restart dictd.service
fi
}
post_remove()
{
if pacman -Qq dictd > /dev/null 2>&1
then
current_conf="$(grep -A 3 "^database *$basename" "$dictd_conf")"
if test -n "$current_conf"
then
echo
if test "$current_conf" = "$conf"
then
echo "Removing configuration for $pkgname from $dictd_conf"
sed -i "/database $basename {/,/}/d" "$dictd_conf"
else
echo "User created / modified configuration" \
"for $pkgname in $dictd_conf is left untouched."
fi
fi
if systemctl -q is-active dictd.service
then
echo "Restarting dictd service in order to" \
"stop using the removed dictionary database"
systemctl restart dictd.service
fi
fi
}
|