diff options
author | respiranto | 2015-08-10 00:52:55 +0200 |
---|---|---|
committer | respiranto | 2015-08-10 00:52:55 +0200 |
commit | 22e346d7d5bead34dd738ed2160e34a210ecb979 (patch) | |
tree | 0312d31ca3c88adb172ed7e0d55282c936cfc7f6 /dict-freedict-spa-eng.install | |
parent | 1f7cb87c90c299f8249de707be157b204a1a1d80 (diff) | |
download | aur-22e346d7d5bead34dd738ed2160e34a210ecb979.tar.gz |
Improved the .install file and made dictd optional
- automated dictd configuration
- notification if dictd is not installed
- (re-)start dictd upon first install
- restart dictd after each upgrade if it was running
Diffstat (limited to 'dict-freedict-spa-eng.install')
-rw-r--r-- | dict-freedict-spa-eng.install | 72 |
1 files changed, 68 insertions, 4 deletions
diff --git a/dict-freedict-spa-eng.install b/dict-freedict-spa-eng.install index cf923dd12079..e0c76c8adab4 100644 --- a/dict-freedict-spa-eng.install +++ b/dict-freedict-spa-eng.install @@ -1,7 +1,71 @@ +pkgname=dict-freedict-spa-eng +basename=spa-eng +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 -e "\nYou have to configure dictd to use the new dictionary" \ - "database located in /usr/share/dictd/ manually" \ - "and restart the dictd service afterwards.\n\n" \ - "See also dictd(8).\n" + 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 -e "$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 + fi } |