jordansissel / pleaserun

An attempt to abstract this "init" script madness.
Other
1.17k stars 80 forks source link

Config woes #152

Open marcbrevoort-cyberhive opened 2 years ago

marcbrevoort-cyberhive commented 2 years ago

There appears to be something fundamental I'm missing on how the combi of fpm and pleaserun deals with (environment) configurations.

I have a sample config file in my .deb package which unpacks to /etc/default/packagename.example.

For this application, this can/should be manually edited and saved to /etc/default/packagename after which the service can be started and the config file is picked up.

However, when I (re)install the .deb package, /etc/default/packagename gets truncated to 0 bytes and the configuration is lost. Moreover, this truncating appears to happen BEFORE the --before-install script is run, thwarting my cunning plan to back it up before install and writing it back afterwards.

So I tried storing the confiuration in /etc/init.d/ instead, which doesn't get overwritten, but it also doesn't get picked up. What's the magic incantation that makes configurations be used and not overwritten each (re)install?

I have tried

But the /etc/default/packagename file keeps getting overwritten. What else could be causing this behaviour?

Update: The "pleaserun" dir contains various 0-length files called /etc/default/packagename

-rw-rw-r-- 0/0               0 2022-06-24 09:59 ./usr/share/pleaserun/packagename/systemd/default/files/etc/default/packagename

Which turned out to be the culprit. Ideally these would not be generated at all, but for now I'm removing any files ending in /etc/default/packagename from the pleaserun directory and that stops pleaserun from killing my configurations.

jordansissel commented 1 year ago

Hmm… this does sound a bit odd. Can you show me your fpm command-line? I’ll see if I can reproduce this behavior with it.

On Fri, Jun 24, 2022, at 1:02 AM, marcbrevoort-cyberhive wrote:

There appears to be something fundamental I'm missing on how the combi of fpm and pleaserun deals with configurations. I have a sample config file in my .deb package which unpacks to /etc/default/myconfig.example.

For this application, this can/should be manually edited and saved to /etc/default/myconfig after which the service can be started and the config file is picked up.

However, when I (re)install the .deb package, /etc/default/myconfig gets truncated to 0 bytes and the configuration is lost. Moreover, this truncating appears to happen BEFORE the --before-install script is run, thwarting my cunning plan to back it up before install and writing it back afterwards.

So I tried storing the confiuration in /etc/init.d/ instead, which doesn't get overwritten, but it also doesn't get picked up. What's the magic incantation that makes configurations be used and not overwritten each (re)install?

— Reply to this email directly, view it on GitHub https://github.com/jordansissel/pleaserun/issues/152, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABAF2SESYAXYDNKHFW5HA3VQVTQPANCNFSM5ZW4ZG7Q. You are receiving this because you are subscribed to this thread.Message ID: @.***>

marcbrevoort-cyberhive commented 11 months ago

the fpm command line creating these empty package files is

fpm -v $VERSIONREVISION -n ${PKGNAME} -s pleaserun -t dir "/usr/bin/${PKGNAME}"

and the above creates blank /etc/default/[packagename] files (unless fixed in the meantime).

The workaround I've had in place for some time is

find ${MYDIR}/${PKGNAME}.dir|grep /etc/default/${PKGNAME}$|xargs rm

As the /etc/default/[packagename] file is no longer present, it is no longer overwriting the existing one, which allows the settings of a previous version to be kept between installs. However it would be nicer if somehow these empty files simply weren't being generated.