Optware / Optware-ng

279 stars 52 forks source link

Leaving the configuration during reinstallation package #22

Closed ghost closed 8 years ago

ghost commented 8 years ago

When you install/update/remove or change the package, eg. reinstall minidlna to minidlna-rescan, existing configuration file (minidlna.conf) is overwritten/removed. Can not you leave it unchanged, and the new, the original configuration file from package set as for example minidlna.conf.ipkg?

alllexx88 commented 8 years ago

This can be done, however, this requires doing this manually for every package with config(s). I like the way it's done by Debian dpkg: configs aren't deleted unless manually requested to (when purging). Unfortunately, though, I'm not familiar with ipkg code, so it's too much work for me to implement such approach.

ElTopo commented 8 years ago

A possible, easier way is, as the official minidlna debian package does, using /etc/default/minidlna

for minidlna's future release package, in init script (i.e., S98minidlna), just after

test -x $DAEMON || exit 0

add

# Read configuration variable file if it is present
[ -r /opt/etc/default/minidlna ] && . /opt/etc/default/minidlna

When user installs this new package, his /opt/etc/minidlna.conf will still be replaced by the new package.

However, the user can create /opt/etc/default/minidlna with

DAEMON_OPTS="-f ${prefix}/etc/myminidlna.conf"

and S98minidlna will start minidlna using user's own configuration file (/opt/etc/myminidlna.conf), that file will never be modified by the new package.

Of course, user is responsible for merging changes in minidlna.conf from the new package.

alllexx88 commented 8 years ago

I believe this is now fixed in latest ipkg-static version:

root@unknown:/tmp/home/root# ipkg update
Downloading http://ipkg.nslu2-linux.org/optware-ng/buildroot-mipsel-ng/Packages.gz.
Inflating http://ipkg.nslu2-linux.org/optware-ng/buildroot-mipsel-ng/Packages.gz.
Updated list of available packages in /opt/lib/ipkg/lists/buildroot-mipsel-ng.
root@unknown:/tmp/home/root# ipkg install lighttpd
Installing lighttpd (1.4.32-1) on root.
Downloading http://ipkg.nslu2-linux.org/optware-ng/buildroot-mipsel-ng/lighttpd_1.4.32-1_mipsel.ipk.
package lighttpd suggests installing e2fsprogs
package lighttpd suggests installing libxml2
package lighttpd suggests installing lua
package lighttpd suggests installing openldap-libs
package lighttpd suggests installing mysql
Installing spawn-fcgi (1.6.3-1) on root.
Downloading http://ipkg.nslu2-linux.org/optware-ng/buildroot-mipsel-ng/spawn-fcgi_1.6.3-1_mipsel.ipk.
Configuring spawn-fcgi.
Configuring lighttpd.
Starting web server: lighttpd
root@unknown:/tmp/home/root# nano /opt/etc/lighttpd/lighttpd.conf
# edit /opt/etc/lighttpd/lighttpd.conf
root@unknown:/tmp/home/root# ipkg remove lighttpd
Removing package lighttpd from root...
Not deleting modified conffile /opt/etc/lighttpd/lighttpd.conf.

ipkg-static is based on opkg 0.2.4, with some OpenWRT patches, and a patch to use ipkg pathes for backward compatibility (installed packages data stored in /opt/lib/ipkg, and /opt/etc/ipkg dir scanned for configs), and opkg 0.2.4 clearly supports this.