From b758d69e6c7a908f2d3e24a71b557e2b4bc00e23 Mon Sep 17 00:00:00 2001 From: Luca Deri Date: Sat, 1 Dec 2018 08:36:58 +0100 Subject: [PATCH] Config files are installed with the .sample extension You can now do 'cp edge.conf.sample edge.conf' to create a n2n configuration. If the .conf (for edge and supernode) are present, the service is enabled automatically. This prevents unwanted services to be enabled, and it preserves services activation across updates --- packages/debian/debian/conffiles | 4 ++-- packages/debian/debian/n2n.debhelper.log | 1 - packages/debian/debian/n2n.postrm.debhelper | 2 +- packages/debian/debian/postinst | 17 ++++++++++---- .../etc/n2n/{edge.conf => edge.conf.sample} | 0 .../{supernode.conf => supernode.conf.sample} | 0 packages/rpm/n2n.spec.in | 23 +++++++++++++------ 7 files changed, 32 insertions(+), 15 deletions(-) rename packages/etc/n2n/{edge.conf => edge.conf.sample} (100%) rename packages/etc/n2n/{supernode.conf => supernode.conf.sample} (100%) diff --git a/packages/debian/debian/conffiles b/packages/debian/debian/conffiles index e2ec868..d467c8b 100644 --- a/packages/debian/debian/conffiles +++ b/packages/debian/debian/conffiles @@ -1,2 +1,2 @@ -/etc/n2n/edge.conf -/etc/n2n/supernode.conf +/etc/n2n/edge.conf.sample +/etc/n2n/supernode.conf.sample diff --git a/packages/debian/debian/n2n.debhelper.log b/packages/debian/debian/n2n.debhelper.log index 4aed2ea..439b7b4 100644 --- a/packages/debian/debian/n2n.debhelper.log +++ b/packages/debian/debian/n2n.debhelper.log @@ -11,4 +11,3 @@ dh_link dh_gencontrol dh_md5sums dh_builddeb -dh_builddeb diff --git a/packages/debian/debian/n2n.postrm.debhelper b/packages/debian/debian/n2n.postrm.debhelper index bc035b9..500916c 100644 --- a/packages/debian/debian/n2n.postrm.debhelper +++ b/packages/debian/debian/n2n.postrm.debhelper @@ -1,4 +1,4 @@ -# Automatically added by dh_installdebconf +# Automatically added by dh_installdebconf/11.1.6ubuntu2 if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then . /usr/share/debconf/confmodule db_purge diff --git a/packages/debian/debian/postinst b/packages/debian/debian/postinst index 0552d02..fb70f9e 100755 --- a/packages/debian/debian/postinst +++ b/packages/debian/debian/postinst @@ -23,12 +23,21 @@ echo "Rebuilding ld cache..." if [ -f /.dockerenv ]; then exit 0; fi # Start service after upgrade/install -echo "(Re)Starting n2n..." systemctl daemon-reload systemctl reset-failed -# Do not start services automatically -#systemctl restart edge -#systemctl restart supernode +# Enable edge +if [ -f /etc/n2n/edge.conf ]; then + echo "Enabling n2n edge..." + systemctl enable edge + systemctl restart edge +fi + +# Enable supernode +if [ -f /etc/n2n/supernode.conf ]; then + echo "Enabling n2n supernode..." + systemctl enable supernode + systemctl restart supernode +fi exit 0 diff --git a/packages/etc/n2n/edge.conf b/packages/etc/n2n/edge.conf.sample similarity index 100% rename from packages/etc/n2n/edge.conf rename to packages/etc/n2n/edge.conf.sample diff --git a/packages/etc/n2n/supernode.conf b/packages/etc/n2n/supernode.conf.sample similarity index 100% rename from packages/etc/n2n/supernode.conf rename to packages/etc/n2n/supernode.conf.sample diff --git a/packages/rpm/n2n.spec.in b/packages/rpm/n2n.spec.in index e9dab7c..66d76cd 100644 --- a/packages/rpm/n2n.spec.in +++ b/packages/rpm/n2n.spec.in @@ -49,8 +49,8 @@ rm -fr $RPM_BUILD_ROOT /usr/lib/systemd/system/edge.service /usr/lib/systemd/system/edge@.service /usr/lib/systemd/system/supernode.service -%config(noreplace) /etc/n2n/supernode.conf -%config(noreplace) /etc/n2n/edge.conf +%config(noreplace) /etc/n2n/supernode.conf.sample +%config(noreplace) /etc/n2n/edge.conf.sample # Set the default attributes of all of the files specified to have an # owner and group of root and to inherit the permissions of the file @@ -72,17 +72,26 @@ rm -fr $RPM_BUILD_ROOT if [ ! -f /.dockerenv ]; then /bin/systemctl daemon-reload -# Do not enable service automatically -#/bin/systemctl enable edge.service -#/bin/systemctl restart edge.service -#/bin/systemctl enable supernode.service -#/bin/systemctl restart supernode.service + if [ -f /etc/n2n/edge.conf ]; then + /bin/systemctl enable edge.service + /bin/systemctl restart edge.service + fi + + if [ -f /etc/n2n/supernode.conf ]; then + /bin/systemctl enable supernode.service + /bin/systemctl restart supernode.service + fi fi %preun if [ ! -f /.dockerenv ]; then +if [ -f /etc/n2n/edge.conf ]; then /bin/systemctl disable edge.service /bin/systemctl stop edge.service +fi + +if [ -f /etc/n2n/supernode.conf ]; then /bin/systemctl disable supernode.service /bin/systemctl stop supernode.service fi +fi