dpkg: How to use trigger?

萝らか妹 提交于 2019-11-29 05:55:20
TLindig

What you are looking for is dpkg-triggers.

One solution with use of debhelper to build the debian packages is this:

Step 1)

Create file debian/<serverPackageName>.triggers (replace <serverPackageName> with name of your server package).

Step 1a)

Define a trigger that watch the directory of your pool. The content of file would be:

interest /path/to/my/pool

Step 1b)

But you can also define a named trigger, which have to be fired explicit (see step 3).

content of file:

interest cdn-pool-changed

The name of the trigger cdn-pool-changed is free. You can take what ever you want.

Step 2)

Add handler for trigger to file debian/<serverPackageName>.postinst (replace <serverPackageName> with name of your server package).

Example:

#!/bin/sh

set -e

case "$1" in
    configure)
    ;;

    triggered)
        #here is the handler 
        /etc/init.d/<serverPackageName> restart
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

#DEBHELPER#

exit 0

Replace <serverPackageName> with name of your server package.

Step 3) (only for named triggers, step 1b) )

Add in every content package the file debian/<contentPackageName>.triggers (replace <contentPackageName> with names of your content packages).

content of file:

activate cdn-pool-changed

Use same name for trigger you defined in step 1.

More detailed Information

The best description for dpkg-triggers I could found is "How to use dpkg triggers". The corresponding git repository with examples you can get here:

git clone git://anonscm.debian.org/users/seanius/dpkg-triggers-example.git

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!