Commit d5284856 authored by Artem Prilutskiy's avatar Artem Prilutskiy

..

parents 37951d1d cdc3d16a
Pipeline #365 failed with stage
in 6 seconds
debian_amd64:
stage: build
script:
- make debian-package
- mkdir build
- cp ../cronos*.deb build/
- rm ../cronos*
only:
- master
artifacts:
paths:
- build/*
tags:
- debian
- amd64
debian_386:
stage: build
script:
- ARCH=i386 make debian-package
- mkdir build
- cp ../cronos*.deb build/
- rm ../cronos*
only:
- master
artifacts:
paths:
- build/*
tags:
- debian
- i386
debian_armhf:
stage: build
script:
- make debian-package
- cp ../cronos*.deb .
- rm ../cronos*
only:
- master
artifacts:
paths:
- cronos*.deb
tags:
- debian
- armv6
......@@ -347,10 +347,17 @@ int main(int argc, const char* argv[])
socketOptionValue = IPTOS_LOWDELAY;
proxySocketAddress.sin_port = 0;
mediaHandle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
<<<<<<< HEAD
if ((mediaHandle < 0) ||
(bind(mediaHandle, (struct sockaddr*)&proxySocketAddress, proxySocketLength) < 0) ||
(getsockname(mediaHandle, (struct sockaddr*)&proxySocketAddress, &proxySocketLength) < 0) ||
(setsockopt(mediaHandle, IPPROTO_IP, IP_TOS, &socketOptionValue, sizeof(socketOptionValue)) < 0))
=======
if((mediaHandle < 0) ||
(bind(mediaHandle, (struct sockaddr*)&proxySocketAddress, proxySocketLength) < 0) ||
(getsockname(mediaHandle, (struct sockaddr*)&proxySocketAddress, &proxySocketLength) < 0) ||
(setsockopt(mediaHandle, IPPROTO_IP, IP_TOS, &socketOptionValue, sizeof(socketOptionValue)) < 0))
>>>>>>> cdc3d16a18388a7244bf6f7b603ede735329266a
{
print("Error opening port for External Server\n");
return EXIT_FAILURE;
......
USE_OPENSSL := no
BUILD := $(shell date -u +%Y%m%d-%H%M%S)
OS := $(shell uname -s)
PREFIX = $(DESTDIR)/opt/CronosAgent
DIRECTORIES =
ifeq ($(OS), Linux)
LIBRARIES += \
rt
# DEPENDENCIES = \
# openssl
FLAGS += -rdynamic
ifeq ($(shell lsb_release -i -s), Debian)
ifeq ($(shell grep -E "^6.0" /etc/debian_version > /dev/null ; echo $?), 0)
LIBRARIES += rt
endif
endif
ifeq ($(USE_OPENSSL), yes)
FLAGS += -DUSE_OPENSSL
DEPENDENCIES += openssl
endif
endif
ifeq ($(OS), Darwin)
# CFLAGS += \
# -Wno-deprecated-declarations \
# -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdk/MacOSX.sdk/usr/include/
# LIBRARIES += \
# crypto
FLAGS += -Wno-deprecated-declarations
ifeq ($(USE_OPENSSL), yes)
FLAGS += -DUSE_OPENSSL -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdk/MacOSX.sdk/usr/include/
LIBRARIES += crypto
endif
endif
OBJECTS = \
sha256.o \
RingBuffer.o \
CronosAgent.o
FLAGS := -g -fno-omit-frame-pointer -O3 -MMD $(foreach directory, $(DIRECTORIES), -I$(directory)) -DBUILD=\"$(BUILD)\"
LIBS := $(foreach library, $(LIBRARIES), -l$(library))
ifneq ($(USE_OPENSSL), yes)
OBJECTS += sha256.o
endif
FLAGS += -g -fno-omit-frame-pointer -O3 -MMD $(foreach directory, $(DIRECTORIES), -I$(directory)) -DBUILD=\"$(BUILD)\"
LIBS += $(foreach library, $(LIBRARIES), -l$(library))
CC = gcc
CFLAGS += $(FLAGS) -std=gnu99
ifeq ($(OS), Linux)
FLAGS += $(shell pkg-config --cflags $(DEPENDENCIES)) -rdynamic
ifneq ($(strip $(DEPENDENCIES)), )
FLAGS += $(shell pkg-config --cflags $(DEPENDENCIES))
LIBS += $(shell pkg-config --libs $(DEPENDENCIES))
endif
......@@ -59,7 +69,6 @@ clean:
rm -f *.d
version:
# echo "#define VERSION $(shell svn info | grep -E "^Revision:" | grep -o -E "[0-9]+")" > Version.h
echo "#define VERSION $(shell date -u +%Y%m%d)" > Version.h
debian-package:
......@@ -70,4 +79,7 @@ else
dpkg-buildpackage -b -tc
endif
macos-archive: build
zip ../CronosAgent-macOS.zip cronosagent cronosagent.sh cronosagent.conf cronosagent.plist
.PHONY: all build clean install
include $(TOPDIR)/rules.mk
X_DOLLAR:=$$
X_SOURCE_DIR:=$(CURDIR)/source
PKG_NAME:=cronosagent
PKG_VERSION:=$(shell grep -o -E '[0-9]+' source/Version.h)
PKG_VERSION:=$(shell grep -o -E '[0-9]+' $(CURDIR)/source/Version.h)
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_BUILD_DEPENDS:=+libstdcpp +libopenssl
X_SOURCE_DIR:=$(CURDIR)/source
PKG_BUILD_DEPENDS:=
include $(INCLUDE_DIR)/package.mk
......@@ -17,49 +19,60 @@ DEPENDS:=
endef
define Package/cronosagent/description
CronosAgent for BrandMeister DMR Master Server
Allows to connect Radio Activity KAIROS Repetaters to BrandMeister DMR Master Server
Radio Activity KAIROS should have built-in feature of External Server Access
which is available on firmware customization 008 (Radio Amateur community)
CronosAgent for BrandMeister DMR Master Server
Allows to connect Radio Activity KAIROS Repetaters to BrandMeister DMR Master Server
Radio Activity KAIROS should have built-in feature of External Server Access
which is available on firmware customization 008 (Radio Amateur community)
endef
define Build/Prepare
echo $(X_SOURCE_DIR)
mkdir -p $(PKG_BUILD_DIR)
$(CP) -R $(X_SOURCE_DIR)/* $(PKG_BUILD_DIR)/
endef
#define Build/Compile
# $(call Build/Compile/Default, -C $(PKG_BUILD_DIR) )
#endef
define Package/cronosagent/conffiles
/etc/config/cronosagent
endef
define Package/cronosagent/postinst
#!/bin/sh
/etc/init.d/cronosagent enable
endef
define Package/cronosagent/prerm
#!/bin/sh
/etc/init.d/cronosagent disable
endef
define Package/cronosagent/install
$(INSTALL_DIR) $(1)/opt/CronosAgent
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/cronosagent
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/cronosagent
$(INSTALL_BIN) $(PKG_BUILD_DIR)/cronosagent $(1)/opt/CronosAgent/
$(INSTALL_BIN) $(X_SOURCE_DIR)/cronosagent.sh $(1)/opt/CronosAgent/
$(INSTALL_BIN) $(X_SOURCE_DIR)/OpenWRT/init.d/cronosagent $(1)/etc/init.d/
$(INSTALL_DATA) $(X_SOURCE_DIR)/OpenWRT/config/cronosagent $(1)/etc/config/
$(INSTALL_DATA) $(X_SOURCE_DIR)/OpenWRT/controller/cronosagent.lua $(1)/usr/lib/lua/luci/controller/
$(INSTALL_DATA) $(X_SOURCE_DIR)/OpenWRT/view/cronosagent/restart.htm $(1)/usr/lib/lua/luci/view/cronosagent/
$(INSTALL_DATA) $(X_SOURCE_DIR)/OpenWRT/model/cbi/cronosagent/configure.lua $(1)/usr/lib/lua/luci/model/cbi/cronosagent/
endef
$(eval $(call BuildPackage,cronosagent))
define Package/cronosagent/conffiles
/etc/config/cronosagent
endef
define Package/cronosagent/postinst
#!/bin/sh
/etc/init.d/cronosagent enable
/etc/init.d/cronosagent start
grep cronosagent /etc/crontabs/root > /dev/null
if [ "$(X_DOLLAR)?" -eq "1" ]
then
cat << EOF >> /etc/crontabs/root
*/10 * * * * test -n "$(X_DOLLAR)(ls /etc/rc.d/S??cronosagent)" -a -z "$(X_DOLLAR)(pidof cronosagent)" && /etc/init.d/cronosagent start
EOF
fi
/etc/init.d/cron enable
/etc/init.d/cron start
exit 0
endef
define Package/cronosagent/prerm
#!/bin/sh
/etc/init.d/cronosagent stop
/etc/init.d/cronosagent disable
exit 0
endef
$(eval $(call BuildPackage,cronosagent))
......@@ -2,13 +2,10 @@
PACKAGE=cronosagent
PROJECT=$(pwd)/..
OPENWRT=${HOME}/openwrt
PROJECT=$(readlink -f $0 | xargs dirname)/..
OPENWRT=$HOME/openwrt
test -d $OPENWRT/package/$PACKAGE
STATE=$?
if [ "$STATE" -eq "0" ]
if [ -d $OPENWRT/package/$PACKAGE ]
then
# Remove existing package in buildroot
rm -rf $OPENWRT/package/$PACKAGE
......@@ -23,23 +20,20 @@ pushd . > /dev/null
cd $OPENWRT
if [ "$STATE" -eq "1" ]
then
# Build predefined packages for the first run
make
fi
# Make Makefile visible to Buildroot
mv package/$PACKAGE/source/OpenWRT/Makefile package/$PACKAGE
if [ "$STATE" -eq "1" ]
grep "CONFIG_PACKAGE_${PACKAGE}=m" .config > /dev/null
if [ "$?" -ne "0" ]
then
# Give user to choose package $PACKAGE
make menuconfig
# Simulate user selection of package $PACKAGE
echo "CONFIG_PACKAGE_${PACKAGE}=m" >> .config
#
# make -j 4
fi
# Build package
make package/$PACKAGE/compile V=99 2>&1 | tee $PROJECT/../build.log | grep -i error
make package/$PACKAGE/compile V=ws 2>&1 | tee $PROJECT/../build.log | grep -i error
# Copy built packages
find bin -name ${PACKAGE}*.ipk | xargs -l -I {} mv {} $PROJECT/..
......
......@@ -3,12 +3,5 @@ module("luci.controller.cronosagent", package.seeall)
function index()
entry({ "admin", "cronosagent" }, alias("admin", "cronosagent", "configure", "restart"), "CronosAgent")
entry({ "admin", "cronosagent", "configure" }, cbi("cronosagent/configure"), "Configure", 10)
entry({ "admin", "cronosagent", "restart" }, call("restartCronosAgent"), "Restart", 20)
end
function restartCronosAgent()
luci.sys.init.stop("cronosagent")
luci.sys.init.start("cronosagent")
luci.http.write("Done!")
-- luci.http.redirect("/")
entry({ "admin", "cronosagent", "restart" }, template("cronosagent/restart"), "Restart", 20)
end
#!/bin/sh /etc/rc.common
START=10
START=40
STOP=15
start() {
......@@ -10,3 +10,7 @@ start() {
stop() {
killall cronosagent
}
reload() {
restart
}
\ No newline at end of file
......@@ -3,15 +3,19 @@ local map = Map("cronosagent", "CronosAgent")
local section = map:section(TypedSection, "cronosagent", "Configuration")
local number = section:option(Value, "number", "Repeater ID", "DMR ID assigned to your repeater" )
local repeater = section:option(Value, "repeaterAddress", "Repeater Address", "Address of your KAIROS repeater" )
local repeater = section:option(Value, "repeaterAddress", "Repeater address", "Address of your KAIROS repeater" )
local server = section:option(Value, "serverAddress", "Server address", "Address of BrandMeister DMR Server")
local password = section:option(Value, "serverPassword", "Password", "Password to login to the server" )
number.datatype = "range(1,16777215)"
repeater.datatype = "ip4addr"
number.datatype = "range(1,16777215)"
repeater.datatype = "ip4addr"
server.datatype = "host"
password.datatype = "string"
password.password = true
server.datatype = "host"
password.datatype = "string"
password.password = true
function map.on_after_commit(self)
luci.sys.call("/etc/init.d/cronosagent restart")
end
return map
\ No newline at end of file
/usr/lib/lua/luci/controller/cronosagent.lua
/usr/lib/lua/luci/model/cbi/cronosagent/configure.lua
/etc/config/cronosagent
/etc/init.d/cronosagent
Copy OpenWRT/package/Makefile -> ~/openwrt/packages/cronosagent/Makefile
Copy * -> ~/openwrt/packages/cronosagent/source/*
Remove ~/openwrt/packages/cronosagent/source/OpenWRT/package/Makefile
\ No newline at end of file
<%
luci.sys.call("/etc/init.d/cronosagent restart ; sleep 2")
%>
<%+header%>
<h2 name="content">CronosAgent &#9656; Restart</h2>
<textarea readonly="readonly" wrap="off" rows="20" style="width: 100%"><%= luci.util.exec("logread | grep CronosAgent | tail -n 20") %></textarea>
<%+footer%>
#include "RingBuffer.h"
#include <string.h>
#include <unistd.h>
void PokeData(struct RingBuffer* buffer, uint32_t number, uint8_t* data, size_t length)
{
number %= BUFFER_LENGTH;
buffer->delay += buffer->marks == 0; // Postpone processing if buffer empty
buffer->marks |= 1 << number; // Set processing mark for the record
struct BufferRecord* record = buffer->records + number;
record->length = length;
memcpy(record->data, data, length);
}
void ProcessBuffer(struct RingBuffer* buffer, int handle, struct sockaddr_in* address)
{
if (buffer->marks == 0)
{
// Nothing to process
return;
}
if (buffer->delay > 0)
{
// Processing was postponed
buffer->delay --;
return;
}
size_t mark = 1 << buffer->index;
if (buffer->marks & mark)
{
// Transmit scheduled data
struct BufferRecord* record = buffer->records + buffer->index;
sendto(handle, record->data, record->length, 0, (struct sockaddr*)address, sizeof(struct sockaddr_in));
// Clear processing mark
buffer->marks ^= mark;
}
buffer->index ++;
buffer->index %= BUFFER_LENGTH;
}
#ifndef RINGBUFFER_H
#define RINGBUFFER_H
#include <stdint.h>
#include <stddef.h>
#include <arpa/inet.h>
#ifdef __cplusplus
extern "C"
{
#endif
#define DATA_LENGTH 48
#define BUFFER_LENGTH 16
struct BufferRecord
{
size_t length;
uint8_t data[DATA_LENGTH];
};
struct RingBuffer
{
size_t marks;
size_t delay;
size_t index;
struct BufferRecord records[BUFFER_LENGTH];
};
void PokeData(struct RingBuffer* buffer, uint32_t number, uint8_t* data, size_t length);
void ProcessBuffer(struct RingBuffer* buffer, int handle, struct sockaddr_in* address);
#ifdef __cplusplus
}
#endif
#endif
#define VERSION 20160731
#define VERSION 20160812
#!/bin/bash
#!/bin/sh
SCRIPT=$(readlink -f $0)
DIRECTORY=$(dirname $SCRIPT)
DIRECTORY=$(dirname $0)
if [ -f $DIRECTORY/cronosagent.conf ]
then
# Read configuration from text file
source $DIRECTORY/cronosagent.conf
# Dot is equivalent of bash's source
. $DIRECTORY/cronosagent.conf
fi
if [ -f /etc/config/cronosagent ]
......
cronosagent (20160731) none; urgency=low
* Daily build
-- Artem Prilutskiy <cyanide.burnout@gmail.com> Mon, 01 Aug 2016 14:12:35 +0400
......@@ -3,7 +3,7 @@ Section: unknown
Priority: extra
Maintainer: Artem Prilutskiy <cyanide.burnout@gmail.com>
Build-Depends:
debhelper (>= 5), libssl-dev
debhelper (>= 5)
Standards-Version: 3.8.4
Package: cronosagent
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment