Использование Go-DHT v1.1.0

This commit is contained in:
Victor Chapaev 2024-09-28 12:04:29 +03:00
parent 779441cc5c
commit a507916ff3
Signed by: victor
GPG Key ID: 05ACE065D1EC5CA4
8 changed files with 39 additions and 24 deletions

View File

@ -2,3 +2,7 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Go Reference](https://pkg.go.dev/badge/gitfox.ru/victor/dht-exporter.svg)](https://pkg.go.dev/gitfox.ru/victor/dht-exporter)
![DHT Exporter](https://shields.foxteam.ru/badge/DHT_Exporter-v1.0.6-purple)
![Go DHT](https://shields.foxteam.ru/badge/Go_DHT-v1.1.0-darkgreen)
![Go WiringPi](https://shields.foxteam.ru/badge/Go_WiringPi-v1.1.0-901030)
![Gitea Last Commit](https://shields.foxteam.ru/gitea/last-commit/victor/dht-exporter?gitea_url=https%3A%2F%2Fgitfox.ru)

View File

@ -2,3 +2,7 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Go Reference](https://pkg.go.dev/badge/gitfox.ru/victor/dht-exporter.svg)](https://pkg.go.dev/gitfox.ru/victor/dht-exporter)
![DHT Exporter](https://shields.foxteam.ru/badge/DHT_Exporter-v1.0.6-purple)
![Go DHT](https://shields.foxteam.ru/badge/Go_DHT-v1.1.0-darkgreen)
![Go WiringPi](https://shields.foxteam.ru/badge/Go_WiringPi-v1.1.0-901030)
![Gitea Last Commit](https://shields.foxteam.ru/gitea/last-commit/victor/dht-exporter?gitea_url=https%3A%2F%2Fgitfox.ru)

2
go.mod
View File

@ -2,4 +2,4 @@ module gitfox.ru/victor/dht-exporter
go 1.22
require gitfox.ru/victor/go-dht v1.0.5
require gitfox.ru/victor/go-dht v1.1.0

View File

@ -1,10 +1,17 @@
# Install DHT Exporter service
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Go Reference](https://pkg.go.dev/badge/gitfox.ru/victor/dht-exporter.svg)](https://pkg.go.dev/gitfox.ru/victor/dht-exporter)
![Go DHT](https://shields.foxteam.ru/badge/Go_DHT-v1.1.0-darkgreen)
![DHT Exporter](https://shields.foxteam.ru/badge/DHT_Exporter-v1.0.6-darkgreen)
![Go WiringPi](https://shields.foxteam.ru/badge/Go_WiringPi-v1.1.0-901030)
![Last Commit](https://shields.foxteam.ru/gitea/last-commit/victor/go-dht?gitea_url=https%3A%2F%2Fgitfox.ru)
1. Run make in the parent directory - **dht-exporter** application must be created.
2. Edit file **service.conf**:
- `InstallPrefix` - **dht-exporter** install location (default: */bin*).
- `EnvirionmentPrefix` - environment configuration location (default: */etc/default*).
- `User` - service user (default: *nobody*).
- `User` - service user (default: *root*).
- `Options` - command-line options. Use *dht-exporter -h* for help.
3. Run installation script
```shell

View File

@ -1,4 +1,4 @@
#
# Command-line options for DHT Exporter
# Command-line options for Prometheus DHT Exporter
#
%%OPTS%%

View File

@ -4,24 +4,24 @@ svcName="dht-exporter"
systemdPath="/usr/lib/systemd/system"
if [ $UID != 0 ]; then
echo "You must have root privilges!"
echo "You must have a root privilges!"
exit 1
fi
if [ ! -x ../$svcName ]; then
echo "FAILED: '$svcName' not found in the parent directory!"
echo "Use make to build app..."
echo "Use 'make' command to build application."
exit 1
fi
. service.conf || {
echo "WARNING: Service comfiguration is not found!"
echo "Using default parameters..."
echo "WARNING: Service configuration not found!"
echo "Using default options."
}
InstallPrefix=${InstallPrefix:-/usr/bin}
EnvironmentPrefix=${EnvironmentPrefix:-/etc/default}
User=${User:-nobody}
User=${User:-root}
echo "Service location : $InstallPrefix/$svcName"
echo "Environment path : $EnvironmentPrefix/$svcName"
@ -42,5 +42,4 @@ rm -f /tmp/$svcName.service
systemctl daemon-reload
systemctl enable dht-exporter.service
systemctl start dht-exporter.service
echo "Install complete!"

View File

@ -1,4 +1,4 @@
InstallPrefix=/bin
EnvironmentPrefix=/etc/default
User=nobody
Options="-pin 7 -data-file=/tmp/dht22.txt"
User=root
Options="-pin 7 -data-file=/var/log/dht22.txt"

View File

@ -5,26 +5,27 @@ systemdPath="/usr/lib/systemd/system"
systemdLink="/etc/systemd/system"
if [ $UID != 0 ]; then
echo "You must have root privilges!"
echo "You must have a root privilges!"
exit 1
fi
. service.conf || {
echo "WARNING: Service comfiguration is not found!"
echo "Using default parameters..."
echo "WARNING: Service configuration not found!"
echo "Using default options."
}
InstallPrefix=${InstallPrefix:-/usr/bin}
EnvironmentPrefix=${EnvironmentPrefix:-/etc/default}
User=${User:-nobody}
User=${User:-root}
if [ -f "$systemdPath/$svcName.service" ]; then
systemctl stop $svcName.service
systemctl disable $svcName.service
rm -f $InstallPrefix/dht-exporter $EnvironmentPrefix/dht-exporter $systemdLink/$svcName.service $systemdPath/$svcName.service
systemctl daemon-reload
echo "Uninstall complete!"
else
echo "Service $svcName is not installed!"
if [ ! -f "$systemdPath/$svcName.service" ]; then
echo "Service $svcName not installed!"
exit 1
fi
echo "Uninstalling service..."
systemctl stop $svcName.service
systemctl disable $svcName.service
rm -f $InstallPrefix/dht-exporter $EnvironmentPrefix/dht-exporter $systemdLink/$svcName.service $systemdPath/$svcName.service
systemctl daemon-reload
echo "Uninstall complete!"