From 2ba7ca7da1acbed470ec2f9d1453120ecb71efde Mon Sep 17 00:00:00 2001 From: Haruue Icymoon Date: Wed, 20 Jul 2022 22:12:52 +0800 Subject: [PATCH] version: 2.0.0 added systemd configs & build scripts, prepared for release --- .gitignore | 1 + cmd/mwgp/main.go | 2 +- release/build.sh | 23 +++++++++++++++++++++++ release/mwgp-client@.service | 20 ++++++++++++++++++++ release/mwgp-server@.service | 20 ++++++++++++++++++++ release/sysusers.conf | 1 + release/tmpfiles.conf | 1 + 7 files changed, 67 insertions(+), 1 deletion(-) create mode 100755 release/build.sh create mode 100644 release/mwgp-client@.service create mode 100644 release/mwgp-server@.service create mode 100644 release/sysusers.conf create mode 100644 release/tmpfiles.conf diff --git a/.gitignore b/.gitignore index 9097a42..7029c6f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /.idea *.exe +/mwgp diff --git a/cmd/mwgp/main.go b/cmd/mwgp/main.go index 8def0a5..32b4847 100644 --- a/cmd/mwgp/main.go +++ b/cmd/mwgp/main.go @@ -13,7 +13,7 @@ import ( ) var ( - MWGPVersion = "2.0.0" + MWGPVersion = "Unknown" ) var rootCmd = cobra.Command{ diff --git a/release/build.sh b/release/build.sh new file mode 100755 index 0000000..c2078fc --- /dev/null +++ b/release/build.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +grt() { + cd "$(git rev-parse --show-toplevel || echo ".")" +} + +version_dirty() { + git diff --quiet || echo '-dirty' +} + +version() { + git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' +} + +_goldflags="-X 'main.MWGPVersion=$(version)$(version_dirty)'" + +grt + +go build \ + -o mwgp \ + -ldflags "$_goldflags" \ + ./cmd/mwgp + diff --git a/release/mwgp-client@.service b/release/mwgp-client@.service new file mode 100644 index 0000000..5bdaf28 --- /dev/null +++ b/release/mwgp-client@.service @@ -0,0 +1,20 @@ +[Unit] +Description=Multi-WireGuard Proxy Client for %i +After=network-online.target nss-lookup.target +Wants=network-online.target nss-lookup.target + +[Service] +Type=simple +ExecStart=/usr/bin/mwgp client %i.json +WorkingDirectory=/etc/mwgp +Environment=MWGP_CACHE_FILE=/var/cache/mwgp/%i.json +User=mwgp +Group=mwgp +Restart=on-failure +CapabilityBoundingSet=CAP_NET_BIND_SERVICE +AmbientCapabilities=CAP_NET_BIND_SERVICE +NoNewPrivileges=true + +[Install] +WantedBy=multi-user.target + diff --git a/release/mwgp-server@.service b/release/mwgp-server@.service new file mode 100644 index 0000000..4b04c51 --- /dev/null +++ b/release/mwgp-server@.service @@ -0,0 +1,20 @@ +[Unit] +Description=Multi-WireGuard Proxy Server for %i +After=network-online.target +Wants=network-online.target + +[Service] +Type=simple +ExecStart=/usr/bin/mwgp server %i.json +WorkingDirectory=/etc/mwgp +Environment=MWGP_CACHE_FILE=/var/cache/mwgp/%i.json +User=mwgp +Group=mwgp +Restart=on-failure +CapabilityBoundingSet=CAP_NET_BIND_SERVICE +AmbientCapabilities=CAP_NET_BIND_SERVICE +NoNewPrivileges=true + +[Install] +WantedBy=multi-user.target + diff --git a/release/sysusers.conf b/release/sysusers.conf new file mode 100644 index 0000000..c9c2216 --- /dev/null +++ b/release/sysusers.conf @@ -0,0 +1 @@ +u mwgp - "Multi-WireGuard Proxy" diff --git a/release/tmpfiles.conf b/release/tmpfiles.conf new file mode 100644 index 0000000..6305596 --- /dev/null +++ b/release/tmpfiles.conf @@ -0,0 +1 @@ +d /var/cache/mwgp 0755 mwgp mwgp