Bläddra i källkod

Merge pull request #1121 from asymetrixs/master

Added workflow to  build debian/ubuntu packages
release/3.x.x
Christian 3 år sedan
committed by GitHub
förälder
incheckning
375ee5c4ac
Ingen känd nyckel hittad för denna signaturen i databasen GPG-nyckel ID: 4AEE18F83AFDEB23
7 ändrade filer med 182 tillägg och 0 borttagningar
  1. +62
    -0
      .github/workflows/deb-packaging.yml
  2. +10
    -0
      Build/deb-meta/DEBIAN/control
  3. +26
    -0
      Build/deb-meta/DEBIAN/copyright
  4. +44
    -0
      Build/deb-meta/DEBIAN/postinst
  5. +8
    -0
      Build/deb-meta/DEBIAN/postrm
  6. +18
    -0
      Build/deb-meta/DEBIAN/prerm
  7. +14
    -0
      Build/deb-meta/etc/systemd/system/mqttnet-server.service

+ 62
- 0
.github/workflows/deb-packaging.yml Visa fil

@@ -0,0 +1,62 @@
# This is a basic workflow to help you get started with Actions

name: Deb Packaging

# Controls when the action will run.
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Parse version
run: echo VERSION=$(grep '<Version>' Source/MQTTnet.Server/MQTTnet.Server.csproj | grep [0-9\.]* -o) >> $GITHUB_ENV

- name: Build MQTTnetServer
run: dotnet publish Source/MQTTnet.Server/MQTTnet.Server.csproj --configuration Release --self-contained --runtime linux-x64 --framework net5.0

- name: Set up installation directory
run: mkdir -p packaging/opt/MQTTnetServer

- name: Copy meta data
run: |
cp -R Build/deb-meta/* packaging/
chmod 755 packaging/DEBIAN/postinst
chmod 755 packaging/DEBIAN/postrm
chmod 755 packaging/DEBIAN/prerm

- name: Move artifacts to packaging directory
run: cp -R Source/MQTTnet.Server/bin/Release/net5.0/linux-x64/publish/* packaging/opt/MQTTnetServer

- name: Adjust files
run: |
rm packaging/opt/MQTTnetServer/appsettings.Development.json
mv packaging/opt/MQTTnetServer/appsettings.json packaging/opt/MQTTnetServer/appsettings.template.json

- name: Adjust permissions
run: |
cd packaging/opt/MQTTnetServer
find . -type f | xargs chmod -R 644
chmod 755 MQTTnet.Server

- name: Generate MD5s
run: |
cd packaging/
md5sum $(find * -type f -not -path 'DEBIAN/*') > DEBIAN/md5sums
- name: Patch meta
run: sed -i 's/\VERSIONPLACEHOLDER/${{ env.VERSION }}/' packaging/DEBIAN/control

- name: Package everything
run: dpkg-deb -v --build packaging/ mqttnet-server_${{ env.VERSION }}-1_amd64.deb
- name: Save artifact
uses: actions/upload-artifact@v2
with:
name: mqttnet-server
path: mqttnet-server_${{ env.VERSION }}-1_amd64.deb

+ 10
- 0
Build/deb-meta/DEBIAN/control Visa fil

@@ -0,0 +1,10 @@
Package: mqttnet-server
Version: VERSIONPLACEHOLDER
Section: base
Priority: optional
Architecture: amd64
Depends: libssl1.1
Suggests:
Maintainer: Damian Wolgast <packages@asymetrixs.net>
Description:
MQTTnet Server is a standalone cross platform MQTT server (like mosquitto) basing on this library.

+ 26
- 0
Build/deb-meta/DEBIAN/copyright Visa fil

@@ -0,0 +1,26 @@
The source of MQTTnet is at:
https://github.com/chkr1011/MQTTnet
Project is maintained by Christian Kratky


MIT License

Copyright (c) 2021 Damian Wolgast

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.

+ 44
- 0
Build/deb-meta/DEBIAN/postinst Visa fil

@@ -0,0 +1,44 @@
#!/bin/bash

# Check if user exits
USER=mqttnetsrv
USEREXISTS=$(id -u $USER >/dev/null 2>&1; echo $?)
EC=0
BASEPATH=/opt
INSTALLPATH=$BASEPATH/MQTTnetServer

# If user does not exist, create it
if (( $USEREXISTS == 1 )); then
useradd -d $INSTALLPATH -r $USER
EC=$(echo $?)

if (( $EC == 1 )); then
exit 1;
fi
fi

# Set permissions on files
chown -R root:root $INSTALLPATH

# Check if config does not exist and create it
if [ ! -f "$INSTALLPATH/appsettings.json" ]; then
cp $INSTALLPATH/appsettings.template.json $INSTALLPATH/appsettings.json
fi


# Check if setcap exists, does not exist in docker containers
SCAP=$(which setcap >/dev/null; echo $?)
if [ "$SCAP" -eq "0" ]; then
# Enable MQTTServer.NET to bind to IP interface
setcap CAP_NET_BIND_SERVICE=+eip $INSTALLPATH/MQTTnet.Server
fi

chmod 644 /etc/systemd/system/mqttnet-server.service

# Check if systemctl exists, does not exist in docker containers
SCTL=$(which systemctl >/dev/null; echo $?)

if [ "$SCTL" -eq "0" ]; then
# Reload systemd because of new service file
systemctl daemon-reload
fi

+ 8
- 0
Build/deb-meta/DEBIAN/postrm Visa fil

@@ -0,0 +1,8 @@
#!/bin/bash

# Check if systemctl exists, does not exist in docker containers
SCTL=$(which systemctl >/dev/null; echo $?)
if [ "$SCTL" -eq "0" ]; then
# Reload systemd because of new service file
systemctl daemon-reload
fi

+ 18
- 0
Build/deb-meta/DEBIAN/prerm Visa fil

@@ -0,0 +1,18 @@
#!/bin/bash

BASEPATH=/opt
INSTALLPATH=$BASEPATH/MQTTnetServer

# Check if systemctl exists, does not exist in docker containers
SCTL=$(which systemctl >/dev/null; echo $?)
if [ "$SCTL" -eq "0" ]; then
# Stop service before uninstalling
systemctl stop mqttnet-server
fi

# Check if setcap exists, does not exist in docker containers
SCAP=$(which setcap >/dev/null; echo $?)
if [ "$SCAP" -eq "0" ]; then
# Remove permission to open ports
setcap CAP_NET_BIND_SERVICE=-eip $INSTALLPATH/MQTTnet.Server
fi

+ 14
- 0
Build/deb-meta/etc/systemd/system/mqttnet-server.service Visa fil

@@ -0,0 +1,14 @@
[Unit]
Description=MQTTnetServer
After=network.target

[Service]
ExecStart=/opt/MQTTnetServer/MQTTnet.Server
WorkingDirectory=/opt/MQTTnetServer
StandardOutput=inherit
StandardError=inherit
Restart=always
User=mqttnetsrv

[Install]
WantedBy=multi-user.target

Laddar…
Avbryt
Spara