Skip to content

Commit

Permalink
Create debian packages to simplifies installation.
Browse files Browse the repository at this point in the history
closes #53
  • Loading branch information
chr-fritz committed Jul 2, 2023
1 parent ca1336a commit 4a21a40
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,42 @@ brews:
bash_completion.install "completions/knx-exporter.bash" => "knx-exporter"
zsh_completion.install "completions/knx-exporter.zsh" => "_knx-exporter"
fish_completion.install "completions/knx-exporter.fish"
nfpms:
- package_name: knx-exporter
file_name_template: "{{ .ConventionalFileName }}"
builds:
- knx-exporter
vendor: chr-fritz
homepage: https://github.com/chr-fritz/knx-exporter
maintainer: chr-fritz<chr-fritz@users.noreply.github.com>
license: Apache 2.0
formats:
- deb
bindir: /usr/bin
contents:
# Config
- src: scripts/defaultGaConfig.yaml
dst: /etc/knx-exporter/ga-config.yaml
type: "config|noreplace"
# systemd
- src: scripts/systemd/knx-exporter.service
dst: /etc/systemd/system/knx-exporter.service
- src: scripts/systemd/knx-exporter.env
dst: /etc/default/knx-exporter
type: "config|noreplace"
- src: scripts/knx-exporter_not_to_be_run
dst: /etc/knx-exporter/knx-exporter_not_to_be_run
type: "config|noreplace"
# Completion
- src: completions/knx-exporter.bash
dst: /usr/share/bash-completion/completions/knx-exporter
- src: completions/knx-exporter.fish
dst: /usr/share/fish/vendor_completions.d/knx-exporter
- src: completions/knx-exporter.zsh
dst: /usr/share/zsh/vendor-completions/_knx-exporter
scripts:
postinstall: "scripts/postinstall.sh"
preremove: "scripts/preremove.sh"
archives:
- files:
- README.md
Expand Down
17 changes: 17 additions & 0 deletions scripts/defaultGaConfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Dummy configuration for a single metric
Connection:
Type: "Tunnel"
Endpoint: "192.168.1.15:3671"
PhysicalAddress: 2.0.1
MetricsPrefix: knx_
AddressConfigs:
0/0/1:
Name: dummy_metric
DPT: 1.*
Export: true
MetricType: "counter"
ReadActive: true
MaxAge: 10m
Comment: dummy comment
Labels:
room: office
1 change: 1 addition & 0 deletions scripts/knx-exporter_not_to_be_run
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Remove this file to allow auto starts of the knx-exporter daemon through systemd.
18 changes: 18 additions & 0 deletions scripts/postinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright © 2022-2023 Christian Fritz <mail@chr-fritz.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

systemctl daemon-reload || true
systemctl enable knx-exporter.service || true
19 changes: 19 additions & 0 deletions scripts/preremove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Copyright © 2022-2023 Christian Fritz <mail@chr-fritz.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

systemctl disable knx-exporter.service || true
systemctl stop knx-exporter.service || true
systemctl daemon-reload || true
4 changes: 4 additions & 0 deletions scripts/systemd/knx-exporter.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
LOG_LEVEL=info
CONFIG_PATH=/etc/knx-exporter/ga-config.yaml
PORT=8080
RESTART_POLICY=exit
20 changes: 20 additions & 0 deletions scripts/systemd/knx-exporter.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[Unit]
Description=KNX Prometheus exporter
After=network.target
ConditionPathExists=!/etc/knx-exporter/knx-exporter_not_to_be_run
[Service]
EnvironmentFile=-/etc/default/knx-exporter
User=root
Type=simple
Restart=on-failure
RestartSec=10
ExecStart=/usr/bin/knx-exporter run --log_level $LOG_LEVEL -f $CONFIG_PATH -r $RESTART_POLICY -p $PORT
KillMode=process

[Install]
WantedBy=multi-user.target
Alias=knx-exporter.service

[Install]
WantedBy=multi-user.target
Alias=knx-exporter.service

0 comments on commit 4a21a40

Please sign in to comment.