From 6c614490051153c881308fef20597b8b93bc9799 Mon Sep 17 00:00:00 2001 From: Tobias Bossert Date: Fri, 7 May 2021 11:38:25 +0200 Subject: [PATCH] deb packaging improvements (file locations /var /etc) --- debian/postinst | 10 +++++++--- debian/rules | 2 +- debian/wg-wrangler.service | 10 ++++++---- etc/Makefile.am | 7 +------ etc/env.dist.conf | 2 ++ etc/wgwrangler.dist.yaml | 2 +- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/debian/postinst b/debian/postinst index 3db6b12b..dfaba954 100644 --- a/debian/postinst +++ b/debian/postinst @@ -14,10 +14,14 @@ chmod g+rwx /etc/wireguard chmod -R g+rw /etc/wireguard # set permissions for /opt/wg-wrangler/etc dir -chgrp --silent --recursive $GROUPNAME /opt/wg-wrangler/etc +chgrp --silent --recursive $GROUPNAME /etc/opt/$PKGNAME/ # set group permissions -chmod -R g+rwx /opt/wg-wrangler/etc +chmod -R g+rwx /etc/opt/$PKGNAME/ + +# create var directory +mkdir -p /var/opt/$PKGNAME +chown --silent --recursive $USERNAME /var/opt/$PKGNAME # Whitelist wg* commands for us -echo "%$GROUPNAME ALL=NOPASSWD: /usr/bin/wg*" >> /etc/sudoers.d/wg-wrangler +echo "%$GROUPNAME ALL=NOPASSWD: /usr/bin/wg*" >> /etc/sudoers.d/$PKGNAME diff --git a/debian/rules b/debian/rules index f2288b5f..84d83ce2 100755 --- a/debian/rules +++ b/debian/rules @@ -11,7 +11,7 @@ export DH_ALWAYS_EXCLUDE=CVS:.svn:.git: override_dh_auto_configure: ./bootstrap - ./configure --prefix=/opt/wg-wrangler + ./configure --prefix=/opt/wg-wrangler --sysconfdir=/etc/opt/wg-wrangler --localstatedir=/var/opt/wg-wrangler %: dh $@ diff --git a/debian/wg-wrangler.service b/debian/wg-wrangler.service index b6fde289..ccb1fbf8 100644 --- a/debian/wg-wrangler.service +++ b/debian/wg-wrangler.service @@ -1,14 +1,16 @@ [Unit] -Description=wg-wranger wireguard manager +Description=wg-wrangler wireguard manager [Service] -Environment=MOJO_MODE=production -Environment=MOJO_LOG_LEVEL=info Type=simple Environment=LISTEN_ON=http://127.0.0.1:7171 Environment=MOJO_MODE=production +Environment=MOJO_LOG_LEVEL=info +Environment=WGwrangler_CONFIG=/etc/opt/wg-wrangler/wgwrangler.yaml + # Environment variables defined in this file (if it exists) override previously defined ones -EnvironmentFile=opt/wg-wrangler/etc/env.conf +EnvironmentFile=-/etc/opt/wg-wrangler/env.conf + User=wg-wrangler_manager Group=wg-wrangler_manager ExecStart=/usr/bin/perl opt/wg-wrangler/bin/wgwrangler.pl prefork --listen $LISTEN_ON diff --git a/etc/Makefile.am b/etc/Makefile.am index 3ffe3844..b7acd7a6 100644 --- a/etc/Makefile.am +++ b/etc/Makefile.am @@ -1,10 +1,5 @@ -ETC = wgwrangler.dist.yaml +ETC = wgwrangler.dist.yaml env.dist.conf EXTRA_DIST = $(ETC) sysconf_DATA = $(ETC) - -wgwrangler.conf: - cp wgwrangler.dist.yaml wgwrangler.yaml - -.PHONY: wgwrangler.conf diff --git a/etc/env.dist.conf b/etc/env.dist.conf index af9d7ed4..b07c0acc 100644 --- a/etc/env.dist.conf +++ b/etc/env.dist.conf @@ -1,2 +1,4 @@ LISTEN_ON=http://127.0.0.1:7171 MOJO_MODE=production +MOJO_LOG_LEVEL=info +WGwrangler_CONFIG=/etc/opt/wg-wrangler/wgwrangler.yaml diff --git a/etc/wgwrangler.dist.yaml b/etc/wgwrangler.dist.yaml index 629579e0..6794c04e 100644 --- a/etc/wgwrangler.dist.yaml +++ b/etc/wgwrangler.dist.yaml @@ -1,6 +1,6 @@ BACKEND: - cfg_db: /tmp/wgwrangler.db + cfg_db: /var/opt/wg-wrangler/wgwrangler.db sesame_user: adfadsfasdf4ee3r # perl -MDigest::SHA -e 'print Digest::SHA::hmac_sha1_hex("access"),"\n"' sesame_pass: 393afhkjhffjj