0

I want to generate a debian package, to install a (webserver) application, running as a service. I now have a package, with only a few warning from lintian (I have left aside the confmodule for later) I am able to install it and it runs as wanted on the target machine. However I frequently run into issues if the init.d scripts need to be updated, as I'm still in a development phase. Thus, I suspect I am not doing the things right.

(Some more details on my case: It is to be installed on a debian11 machine with no network access, thus whl and dependencies are also included in the deb package. Also I want the service to be run as a system user I create during install)

Here is what I have so far:

repository/
- debian/
  - DEBIAN/
    - conffiles
    - config
    - control
    - postinst
    - postrm
    - preinst
    - prerm
    - templates
  - etc/my_app/my_app.conf
  - etc/init.d/my_app
  - lib/systemd/system/my_app.service
  - usr/lib/my_app/whl/
    (... some python whl to load into the virtualenv ...)
  - share/doc/my_app/copyright

- my_app/
  - scriptA.sh
  - scriptB.sh
  - scriptC.sh
  (... stuff ...)

- debianbuildscript.sh
- readme
- changelog.Debian

debian build script:

  • copy needed files from ./my*app to ./debian/usr/lib/my_*app/

  • Copy and gzip the changelog to ./debian/usr/share/doc/my_app/

  • Change directories permissions to 755

then

fakeroot dpkg-deb --build debian

In conffiles:

/etc/init.d/gozer
/etc/gozer/gozer.conf

From what I read, it is not necessary as debian treats everything below /etc as configuration files, but for the matter of avoiding implicit, I have declared them here. Anyway, this is part of my problem.

my_app.service:

[Unit]
Description=my super application
After=network.target

[Service]
Type=simple
ExecStart=/etc/init.d/my_app start

[Install]
WantedBy=multi-user.target

lintian complains here that I should not be calling the init.d script. But I m not sure of what I should do instead?

/etc/init.d/my_app:

Essentially retrieving environment variables, reading the myapp.conf file and running myapp/script{A,B,C}.sh as the system user 'my_app', created by preinst script, depending on var $1.

(For example, to start: )

d_start()
{
    if [ -f $RUNFILES_PATH/$MYAPP_SITE.pid ]; then
        echo -n " already running"
    else
        start-stop-daemon --start --quiet \
                       --pidfile $RUNFILES_PATH/$MYAPP_SITE.pid \
                       --chuid $RUN_AS --chdir $SITE_PATH/$MYAPP_SITE\
                       --exec $SITE_PATH/$MYAPP_SITE/runserver.sh
    fi
}

My problem:

When I remove or update the package with a newer version: /etc/init.d/my_app is left unchanged. (as it is considered a configuration file, that sounds quite strange to me as they are essentially init scripts ?)

Only way is to force install it, with

rm /etc/init.d/my_app
dpkg -i --forceconfmiss ./my_app_X.Y-Z.deb

It does not feel right, any suggestion of improvement ?

a way to tag the init.d file as not a configuration file perhaps ?

What about my current service configuration ?

Pellekrino
  • 346
  • 2
  • 14

0 Answers0