I have a project name snaplogger that I use to send logs to files, syslog, the console, or a remote computer (what syslogd does but with many more features).
Whenever another project wants to use the snaplogger
, it's expected to create a log sub-directory. For example, my communicatord project does that:
PACKAGENAME=communicatord
USERNAME=communicatord
GROUPNAME=communicatord
[...snip...]
LOGDIR=/var/log/${PACKAGENAME}
LOGFILE=${LOGDIR}/${PACKAGENAME}.log
mkdir -p ${LOGDIR}
touch ${LOGFILE}
chown ${USERNAME}:${GROUPNAME} ${LOGFILE}
chmod 640 ${LOGFILE}
What I would like to do is move the last 6 lines to a script that the snaplogger
project provides. Then the communicatord
would just use a function that the script defined. Maybe something like this:
prepare-snaplogger ${PACKAGENAME} ${USERNAME} ${GROUPNAME} true
The true
at the end means we also want a secure log sub-folder.
Since the postinst script is run with root, it can create all of that whereas the service will run as itself (i.e. I have a communicatord
user) so it would not be able to create those folders.
My question here is: is there a documented way of providing such extension scripts in Debian and/or Ubuntu?
My idea is that each project should provide such under /usr/share/<project-name>/[debconf/?]
. But maybe we can use the /var/share/debconf/...
folder?
As a result, I would have one additional line to source that file like the following which would appear near the start of the communicatord.postinst
script:
. /usr/share/snaplogger/debconf