Skip to content

Commit 8313341

Browse files
authored
Better packages (#318)
1 parent 1214867 commit 8313341

13 files changed

Lines changed: 155 additions & 58 deletions

File tree

.fpm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-s dir
22
--name defguard-gateway
3-
--description "Defguard VPN gateway service"
3+
--description "Defguard Gateway service"
44
--url "https://defguard.net/"
55
--maintainer "Defguard"
6-
--config-files /etc/defguard/gateway.toml.sample
6+
--config-files /etc/defguard/gateway.toml

.github/workflows/release.yml

Lines changed: 62 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122,57 +122,101 @@ jobs:
122122
with:
123123
fpm_args:
124124
"defguard-gateway-${{ env.VERSION }}-x86_64-unknown-linux-gnu=/usr/bin/defguard-gateway
125-
defguard-gateway.service=/usr/lib/systemd/system/defguard-gateway.service
126-
example-config.toml=/etc/defguard/gateway.toml.sample"
127-
fpm_opts: "--architecture amd64 --output-type deb --version ${{ env.VERSION }} --package defguard-gateway-${{ env.VERSION }}-x86_64-unknown-linux-gnu.deb --after-install after-install.sh"
125+
linux/defguard-gateway.service=/usr/lib/systemd/system/defguard-gateway.service
126+
example-config.toml=/etc/defguard/gateway.toml"
127+
fpm_opts:
128+
"--architecture amd64
129+
--output-type deb
130+
--version ${{ env.VERSION }}
131+
--package defguard-gateway-${{ env.VERSION }}-x86_64-unknown-linux-gnu.deb
132+
--before-install linux/preinst
133+
--after-install linux/postinst
134+
--before-remove linux/prerm
135+
--after-remove linux/postrm"
128136

129137
- name: Build aarch64 DEB package
130138
uses: defGuard/fpm-action@main
131139
with:
132140
fpm_args:
133141
"defguard-gateway-${{ env.VERSION }}-aarch64-unknown-linux-gnu=/usr/bin/defguard-gateway
134-
defguard-gateway.service=/usr/lib/systemd/system/defguard-gateway.service
135-
example-config.toml=/etc/defguard/gateway.toml.sample"
136-
fpm_opts: "--architecture arm64 --output-type deb --version ${{ env.VERSION }} --package defguard-gateway-${{ env.VERSION }}-aarch64-unknown-linux-gnu.deb --after-install after-install.sh"
142+
linux/defguard-gateway.service=/usr/lib/systemd/system/defguard-gateway.service
143+
example-config.toml=/etc/defguard/gateway.toml"
144+
fpm_opts:
145+
"--architecture arm64
146+
--output-type deb
147+
--version ${{ env.VERSION }}
148+
--package defguard-gateway-${{ env.VERSION }}-aarch64-unknown-linux-gnu.deb
149+
--before-install linux/preinst
150+
--after-install linux/postinst
151+
--before-remove linux/prerm
152+
--after-remove linux/postrm"
137153

138154
- name: Build x86_64 RPM package
139155
uses: defGuard/fpm-action@main
140156
with:
141157
fpm_args:
142158
"defguard-gateway-${{ env.VERSION }}-x86_64-unknown-linux-gnu=/usr/bin/defguard-gateway
143-
defguard-gateway.service=/usr/lib/systemd/system/defguard-gateway.service
144-
example-config.toml=/etc/defguard/gateway.toml.sample"
145-
fpm_opts: "--architecture amd64 --output-type rpm --version ${{ env.VERSION }} --package defguard-gateway-${{ env.VERSION }}-x86_64-unknown-linux-gnu.rpm --after-install after-install.sh"
159+
linux/defguard-gateway.service=/usr/lib/systemd/system/defguard-gateway.service
160+
example-config.toml=/etc/defguard/gateway.toml"
161+
fpm_opts:
162+
"--architecture amd64
163+
--output-type rpm
164+
--version ${{ env.VERSION }}
165+
--package defguard-gateway-${{ env.VERSION }}-x86_64-unknown-linux-gnu.rpm
166+
--before-install linux/preinst
167+
--after-install linux/postinst
168+
--before-remove linux/prerm
169+
--after-remove linux/postrm"
146170

147171
- name: Build aarch64 RPM package
148172
uses: defGuard/fpm-action@main
149173
with:
150174
fpm_args:
151175
"defguard-gateway-${{ env.VERSION }}-aarch64-unknown-linux-gnu=/usr/bin/defguard-gateway
152-
defguard-gateway.service=/usr/lib/systemd/system/defguard-gateway.service
153-
example-config.toml=/etc/defguard/gateway.toml.sample"
154-
fpm_opts: "--architecture arm64 --output-type rpm --version ${{ env.VERSION }} --package defguard-gateway-${{ env.VERSION }}-aarch64-unknown-linux-gnu.rpm --after-install after-install.sh"
176+
linux/defguard-gateway.service=/usr/lib/systemd/system/defguard-gateway.service
177+
example-config.toml=/etc/defguard/gateway.toml"
178+
fpm_opts:
179+
"--architecture arm64
180+
--output-type rpm
181+
--version ${{ env.VERSION }}
182+
--package defguard-gateway-${{ env.VERSION }}-aarch64-unknown-linux-gnu.rpm
183+
--before-install linux/preinst
184+
--after-install linux/postinst
185+
--before-remove linux/prerm
186+
--after-remove linux/postrm"
155187

156188
- name: Build FreeBSD package
157189
uses: defGuard/fpm-action@main
158190
with:
159191
fpm_args:
160192
"defguard-gateway-${{ env.VERSION }}-x86_64-unknown-freebsd=/usr/local/bin/defguard-gateway
161-
defguard-gateway.service.freebsd=/usr/local/etc/rc.d/defguard-gateway
162-
example-config.toml=/etc/defguard/gateway.toml.sample"
163-
fpm_opts: "--architecture amd64 --output-type freebsd --version ${{ env.VERSION }} --package defguard-gateway-${{ env.VERSION }}_x86_64-unknown-freebsd.pkg --freebsd-osversion '*' --depends openssl"
193+
freebsd/defguard-gateway=/usr/local/etc/rc.d/defguard-gateway
194+
example-config.toml=/etc/defguard/gateway.toml"
195+
fpm_opts:
196+
"--architecture amd64
197+
--output-type freebsd
198+
--version ${{ env.VERSION }}
199+
--package defguard-gateway-${{ env.VERSION }}_x86_64-unknown-freebsd.pkg
200+
--freebsd-osversion '*'
201+
--depends openssl"
164202

165203
- name: Build OPNsense package
166204
uses: defGuard/fpm-action@main
167205
with:
168206
fpm_args:
169207
"defguard-gateway-${{ env.VERSION }}-x86_64-unknown-freebsd=/usr/local/bin/defguard-gateway
170-
defguard-gateway.service.freebsd=/usr/local/etc/rc.d/defguard-gateway
171-
example-config.toml=/etc/defguard/gateway.toml.sample
208+
freebsd/defguard-gateway=/usr/local/etc/rc.d/defguard-gateway
209+
example-config.toml=/etc/defguard/gateway.toml
172210
defguard-rc.conf=/etc/rc.conf.d/defguard_gateway
173211
opnsense/src/etc/=/usr/local/etc/
174212
opnsense/src/opnsense/=/usr/local/opnsense/"
175-
fpm_opts: "--architecture amd64 --output-type freebsd --version ${{ env.VERSION }} --package defguard-gateway-${{ env.VERSION }}_x86_64-unknown-opnsense.pkg --freebsd-osversion '*' --depends openssl"
213+
fpm_opts:
214+
"--architecture amd64
215+
--output-type freebsd
216+
--version ${{ env.VERSION }}
217+
--package defguard-gateway-${{ env.VERSION }}_x86_64-unknown-opnsense.pkg
218+
--freebsd-osversion '*'
219+
--depends openssl"
176220

177221
- name: Upload Linux x86_64 archive
178222
uses: shogo82148/actions-upload-release-asset@v1

Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

after-install.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

defguard-gateway.service

Lines changed: 0 additions & 20 deletions
This file was deleted.

docs/header.png

-9.28 KB
Loading

example-config.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# This is an example config file for defguard VPN gateway
2-
# To use it fill in actual values for your deployment below
1+
# This is an example config file for Defguard Gateway.
2+
# To use it fill in actual values for your deployment below.
33

44
# Required: use userspace WireGuard implementation (e.g. wireguard-go)
55
userspace = false
6-
# Required: how often should interface stat updates be sent to defguard server (in seconds)
6+
# Required: how often should interface stat updates be sent to Defguard Core (in seconds)
77
stats_period = 60
88
# Required: name of WireGuard interface
99
ifname = "wg0"
@@ -26,14 +26,13 @@ syslog_socket = "/var/run/log"
2626
# Example: Add a default route after WireGuard interface is up:
2727
#post_up = "/path/to/ip route add default via 192.168.1.1 dev wg0"
2828

29-
3029
# Optional: Command which will be run before bringing interface down
3130
# Example: Remove WireGuard-related firewall rules before interface is taken down:
3231
#pre_down = "/path/to/iptables -D INPUT -i wg0 -j ACCEPT"
3332

3433
# Optional: Command which will be run after bringing interface down
3534
# Example: Remove the default route after WireGuard interface is down:
36-
#post_down = "/pat/to/ip route del default via 192.168.1.1 dev wg0"
35+
#post_down = "/path/to/ip route del default via 192.168.1.1 dev wg0"
3736

3837
# A HTTP port that will expose the REST HTTP gateway health status
3938
# STATUS CODES:
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88

99
name="defguard_gateway"
1010
rcvar=defguard_gateway_enable
11-
command="/usr/local/sbin/defguard-gateway"
11+
command="/usr/local/bin/defguard-gateway"
1212
config="/etc/defguard/gateway.toml"
1313
start_cmd="${name}_start"
1414

15-
defguard_gateway_start()
16-
{
17-
${command} --config ${config} &
15+
defguard_gateway_start() {
16+
${command} --config ${config} &
1817
}
1918

2019
load_rc_config $name

linux/defguard-gateway.service

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[Unit]
2+
Description=Defguard Gateway service
3+
Documentation=https://docs.defguard.net/
4+
Wants=network-online.target
5+
After=network-online.target
6+
7+
[Service]
8+
User=defguard
9+
Group=defguard
10+
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
11+
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
12+
ExecReload=/bin/kill -HUP $MAINPID
13+
ExecStart=/usr/bin/defguard-gateway --config /etc/defguard/gateway.toml
14+
KillMode=process
15+
KillSignal=SIGINT
16+
LimitNOFILE=65536
17+
LimitNPROC=infinity
18+
Restart=on-failure
19+
RestartSec=2
20+
TasksMax=infinity
21+
OOMScoreAdjust=-1000
22+
23+
[Install]
24+
WantedBy=multi-user.target

linux/postinst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
set -e
3+
4+
SERVICE_NAME='defguard-gateway'
5+
6+
case "${1}" in
7+
1 | configure)
8+
if [ -x /usr/bin/systemctl ]; then
9+
/usr/bin/systemctl daemon-reload
10+
/usr/bin/systemctl enable ${SERVICE_NAME}
11+
/usr/bin/systemctl --no-block start ${SERVICE_NAME}
12+
fi
13+
;;
14+
abort-upgrade | abort-remove | abort-deconfigure)
15+
if [ -x /usr/bin/systemctl ]; then
16+
/usr/bin/systemctl daemon-reload
17+
if /usr/bin/systemctl is-enabled --quiet ${SERVICE_NAME}; then
18+
/usr/bin/systemctl --no-block restart ${SERVICE_NAME}
19+
fi
20+
fi
21+
;;
22+
esac

0 commit comments

Comments
 (0)