Доработка сборки deb пакета
This commit is contained in:
9
debian/changelog
vendored
Normal file
9
debian/changelog
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
gpio-monitor-server (1.0.0-1) stable; urgency=medium
|
||||
|
||||
* Initial release
|
||||
* GPIO monitoring with web interface
|
||||
* Systemd service with auto-restart
|
||||
* Log rotation and retention
|
||||
* Support for Raspberry Pi GPIO
|
||||
|
||||
-- НТЦ200 Mon, 23 Jun 2026 12:00:00 +0300
|
||||
14
debian/control
vendored
Normal file
14
debian/control
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
Source: gpio-monitor-server
|
||||
Section: utils
|
||||
Priority: optional
|
||||
Maintainer: НТЦ200 <ntc200@example.com>
|
||||
Build-Depends: debhelper (>= 11), dh-golang, golang-go, npm
|
||||
Standards-Version: 4.5.0
|
||||
Homepage: https://example.com/gpio-monitor
|
||||
Package: gpio-monitor-server
|
||||
Version: 1.0.0-1
|
||||
Architecture: arm64
|
||||
Depends: systemd
|
||||
Description: GPIO Monitor Server
|
||||
Сервер для мониторинга GPIO с веб-интерфейсом
|
||||
и системой логирования.
|
||||
29
debian/copyright
vendored
Normal file
29
debian/copyright
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
Format:
|
||||
Upstream-Name: gpio-monitor-server
|
||||
Source:
|
||||
Files: *
|
||||
Copyright: 2024 НТЦ200
|
||||
License: MIT
|
||||
|
||||
Files: debian/*
|
||||
Copyright: 2024 НТЦ200
|
||||
License: MIT
|
||||
|
||||
License: MIT
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
.
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
5
debian/dirs
vendored
Normal file
5
debian/dirs
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
usr/bin
|
||||
opt/gpio-monitoring/web
|
||||
etc/gpio-monitoring
|
||||
var/log/gpio-monitoring
|
||||
var/lib/gpio-monitoring
|
||||
15
debian/gpio-monitor-server.conf
vendored
Normal file
15
debian/gpio-monitor-server.conf
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# Конфигурация GPIO Monitor Server
|
||||
# Файл: /etc/gpio-monitoring/config
|
||||
|
||||
# Параметры запуска
|
||||
PIPE_PATH=/tmp/gpio_pipe
|
||||
RETENTION_HOURS=72
|
||||
RETENTION_MB=2000
|
||||
RETENTION_INTERVAL=60
|
||||
ROTATION_CHECK_INTERVAL=1
|
||||
BUFFER_SIZE=10240
|
||||
HUMAN_LOG_INTERVAL=5
|
||||
PORT=8080
|
||||
|
||||
# Настройки камеры (если используется)
|
||||
CAMERA_URL=http://127.0.0.1:1984/api/stream.mjpeg?src=cam_mjpeg
|
||||
39
debian/gpio-monitor-server.service
vendored
Normal file
39
debian/gpio-monitor-server.service
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
[Unit]
|
||||
Description=GPIO Monitor Server
|
||||
After=network.target
|
||||
Wants=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=gpio-monitor
|
||||
Group=gpio-monitor
|
||||
WorkingDirectory=/opt/gpio-monitoring
|
||||
|
||||
# Запуск сервера с параметрами
|
||||
ExecStart=/usr/bin/gpio-monitor-server \
|
||||
-pipe /tmp/gpio_pipe \
|
||||
-retention-hours=72 \
|
||||
-retention-mb=2000 \
|
||||
-retention-interval=60 \
|
||||
-rotation-check-interval=1 \
|
||||
-buffer-size=10240 \
|
||||
-human-log-interval=5
|
||||
|
||||
# Перезапуск при падении
|
||||
Restart=on-failure
|
||||
RestartSec=10s
|
||||
|
||||
# Лимиты и безопасность
|
||||
LimitNOFILE=4096
|
||||
NoNewPrivileges=yes
|
||||
|
||||
# Логирование
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
SyslogIdentifier=gpio-monitor
|
||||
|
||||
# Настройки для доступа к GPIO
|
||||
AmbientCapabilities=CAP_SYS_RAWIO
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
2
debian/install
vendored
Normal file
2
debian/install
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
# Бинарник будет установлен в /usr/bin автоматически
|
||||
debian/usr/bin/gpio-logs usr/bin/
|
||||
33
debian/postinst
vendored
Normal file
33
debian/postinst
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
# chmod +x debian/postinst
|
||||
|
||||
set -e
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
# Создаем директории
|
||||
mkdir -p /var/log/gpio-monitoring
|
||||
mkdir -p /var/lib/gpio-monitoring
|
||||
mkdir -p /opt/gpio-monitoring/web
|
||||
|
||||
# Устанавливаем права
|
||||
chown -R gpio-monitor:gpio-monitor /var/log/gpio-monitoring
|
||||
chown -R gpio-monitor:gpio-monitor /var/lib/gpio-monitoring
|
||||
chown -R gpio-monitor:gpio-monitor /opt/gpio-monitoring
|
||||
|
||||
# Перезагружаем systemd
|
||||
systemctl daemon-reload 2>/dev/null || true
|
||||
|
||||
# Включаем сервис, но не запускаем автоматически
|
||||
systemctl enable gpio-monitor-server.service 2>/dev/null || true
|
||||
systemctl start gpio-monitor-server.service
|
||||
|
||||
# Создаем symlink для логов
|
||||
ln -sf /var/log/gpio-monitoring /opt/gpio-monitoring/logs 2>/dev/null || true
|
||||
|
||||
echo "GPIO Monitor Server установлен"
|
||||
echo "Для запуска: sudo systemctl start gpio-monitor-server"
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
19
debian/postrm
vendored
Normal file
19
debian/postrm
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
#chmod +x debian/postrm
|
||||
|
||||
set -e
|
||||
|
||||
case "$1" in
|
||||
purge)
|
||||
# Удаляем пользователя только при полной очистке
|
||||
userdel gpio-monitor 2>/dev/null || true
|
||||
groupdel gpio-monitor 2>/dev/null || true
|
||||
|
||||
# Удаляем директории
|
||||
rm -rf /var/log/gpio-monitoring
|
||||
rm -rf /var/lib/gpio-monitoring
|
||||
rm -rf /opt/gpio-monitoring
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
24
debian/preinst
vendored
Normal file
24
debian/preinst
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
#chmod +x debian/preinst
|
||||
|
||||
set -e
|
||||
|
||||
# Создаем пользователя и группу
|
||||
if ! getent group gpio-monitor >/dev/null; then
|
||||
groupadd --system gpio-monitor
|
||||
fi
|
||||
|
||||
if ! getent passwd gpio-monitor >/dev/null; then
|
||||
useradd --system \
|
||||
--gid gpio-monitor \
|
||||
--home /var/lib/gpio-monitoring \
|
||||
--shell /usr/sbin/nologin \
|
||||
--comment "GPIO Monitor Service" \
|
||||
gpio-monitor
|
||||
fi
|
||||
|
||||
# Добавляем пользователя в нужные группы для доступа к GPIO
|
||||
usermod -a -G gpio,dialout,gpio-monitor gpio-monitor 2>/dev/null || true
|
||||
|
||||
exit 0
|
||||
15
debian/prerm
vendored
Normal file
15
debian/prerm
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
#chmod +x debian/prerm
|
||||
|
||||
set -e
|
||||
|
||||
case "$1" in
|
||||
remove|upgrade|deconfigure)
|
||||
# Останавливаем сервис
|
||||
systemctl stop gpio-monitor-server.service 2>/dev/null || true
|
||||
systemctl disable gpio-monitor-server.service 2>/dev/null || true
|
||||
systemctl daemon-reload 2>/dev/null || true
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
24
debian/rules
vendored
Normal file
24
debian/rules
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
# chmod +x debian/rules
|
||||
# Удаляем стандартные правила
|
||||
%:
|
||||
dh $@ --buildsystem=golang --with=golang
|
||||
|
||||
# Переопределяем сборку
|
||||
override_dh_auto_build:
|
||||
# Сборка фронтенда
|
||||
cd cmd/server/web && npm install && npm run build
|
||||
# Сборка бекенда
|
||||
GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o debian/gpio-monitor-server/usr/bin/gpio-monitor-server ./cmd/server
|
||||
|
||||
# Установка файлов
|
||||
override_dh_install:
|
||||
dh_install
|
||||
# Копируем статические файлы для веба
|
||||
mkdir -p debian/gpio-monitor-server/opt/gpio-monitoring/web
|
||||
cp -r cmd/server/web/dist debian/gpio-monitor-server/opt/gpio-monitoring/web/
|
||||
cp -r cmd/server/web/css debian/gpio-monitor-server/opt/gpio-monitoring/web/
|
||||
cp -r cmd/server/web/fonts debian/gpio-monitor-server/opt/gpio-monitoring/web/
|
||||
cp cmd/server/web/*.html debian/gpio-monitor-server/opt/gpio-monitoring/web/ 2>/dev/null || true
|
||||
cp cmd/server/web/favicon.png debian/gpio-monitor-server/opt/gpio-monitoring/web/ 2>/dev/null || true
|
||||
31
debian/usr/bin/gpio-logs
vendored
Normal file
31
debian/usr/bin/gpio-logs
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
# Просмотр логов GPIO Monitor
|
||||
|
||||
if [ "$1" = "-f" ]; then
|
||||
sudo journalctl -u gpio-monitor-server -f
|
||||
elif [ "$1" = "-e" ]; then
|
||||
sudo tail -f /var/log/gpio-monitoring/events_human.log
|
||||
elif [ "$1" = "-g" ]; then
|
||||
sudo tail -f /var/log/gpio-monitoring/gpio_human.log
|
||||
elif [ "$1" = "-d" ]; then
|
||||
sudo tail -f /var/log/gpio-monitoring/data/*.bin 2>/dev/null | xxd
|
||||
elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||
echo "Использование: gpio-logs [OPTION]"
|
||||
echo " -f Просмотр логов сервиса (journalctl)"
|
||||
echo " -e Просмотр логов событий"
|
||||
echo " -g Просмотр GPIO логов (human-readable)"
|
||||
echo " -d Просмотр бинарных данных (raw)"
|
||||
echo " -h Показать эту справку"
|
||||
else
|
||||
echo "Использование: gpio-logs [OPTION]"
|
||||
echo " -f Просмотр логов сервиса (journalctl)"
|
||||
echo " -e Просмотр логов событий"
|
||||
echo " -g Просмотр GPIO логов (human-readable)"
|
||||
echo " -d Просмотр бинарных данных (raw)"
|
||||
echo " -h Показать эту справку"
|
||||
echo ""
|
||||
echo "Примеры:"
|
||||
echo " gpio-logs -f # следить за логами сервиса"
|
||||
echo " gpio-logs -e # смотреть события"
|
||||
echo " gpio-logs -g # смотреть GPIO логи"
|
||||
fi
|
||||
Reference in New Issue
Block a user