diff options
author | respiranto | 2015-08-23 23:49:48 +0200 |
---|---|---|
committer | respiranto | 2015-08-23 23:49:48 +0200 |
commit | b1cf22d835c1cec1b61247e8e0f98d61ae32455a (patch) | |
tree | 1189c0c6550fddcba8fdd6b9c7cb2c6150119d66 /dict-foldoc.install | |
download | aur-b1cf22d835c1cec1b61247e8e0f98d61ae32455a.tar.gz |
Aimed to replace / rename dictd-foldoc
changes in comparison to current dictd-foldoc:
- update to version from 2015-08-21 08:11:48 UTC
- added restart of dictd after removal in install file
Diffstat (limited to 'dict-foldoc.install')
-rw-r--r-- | dict-foldoc.install | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/dict-foldoc.install b/dict-foldoc.install new file mode 100644 index 000000000000..c3a1e9b69d61 --- /dev/null +++ b/dict-foldoc.install @@ -0,0 +1,78 @@ +pkgname=dict-foldoc +basename=foldoc +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 +} |