From d71335b6ccb2b71e846736bc8e7e8a3ccc954b7f Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 12 May 2015 01:22:33 +0200 Subject: removed old seperate directories diff --git a/rhnop-client/Makefile b/rhnop-client/Makefile deleted file mode 100644 index 8eb3860..0000000 --- a/rhnop-client/Makefile +++ /dev/null @@ -1,77 +0,0 @@ -## -## rhnop -## -## Copyright (C) 2011-2014 Christian Pointner -## -## This file is part of rhnop. -## -## rhnop is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## any later version. -## -## rhnop is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with rhnop. If not, see . -## - -ifneq ($(MAKECMDGOALS),distclean) -include include.mk -endif - -EXECUTABLE := nopcollectd - -.PHONY: clean distclean install install-bin install-etc uninstall remove purge - -all: $(EXECUTABLE) - -distclean: clean - find . -name *.o -exec rm -f {} \; - find . -name "*.\~*" -exec rm -rf {} \; - rm -f include.mk - -clean: - -INSTALL_TARGETS := install-bin install-lib install-etc -REMOVE_TARGETS := remove-bin remove-lib remove-etc - -install: all $(INSTALL_TARGETS) - -install-bin: $(EXECUTABLE) - $(INSTALL) -d $(DESTDIR)$(BINDIR) - $(INSTALL) -m 755 $(EXECUTABLE) $(DESTDIR)$(BINDIR) - $(SED) -e 's#^conffile = "nopcollectd#conffile = "$(ETCDIR)/rhnop/nopcollectd#' -i $(DESTDIR)$(BINDIR)/$(EXECUTABLE) - $(SED) -e 's#_rhnoplibdir_/?.lua#$(LIBDIR)/?.lua#' -i $(DESTDIR)$(BINDIR)/$(EXECUTABLE) - $(INSTALL) -m 755 nopsysstated $(DESTDIR)$(BINDIR) - $(SED) -e 's#^conffile = "nopsysstated#conffile = "$(ETCDIR)/rhnop/nopsysstated#' -i $(DESTDIR)$(BINDIR)/nopsysstated - $(SED) -e 's#_rhnoplibdir_/?.lua#$(LIBDIR)/?.lua#' -i $(DESTDIR)$(BINDIR)/nopsysstated - -install-lib: - $(INSTALL) -d $(DESTDIR)$(LIBDIR) - $(INSTALL) -m 644 conf.lua $(DESTDIR)$(LIBDIR) - $(INSTALL) -m 644 db.lua $(DESTDIR)$(LIBDIR) - -install-etc: - $(INSTALL) -d $(DESTDIR)$(ETCDIR)/rhnop - $(INSTALL) -m 640 nopcollectd.*.conf $(DESTDIR)$(ETCDIR)/rhnop - $(INSTALL) -m 640 nopsysstated.conf $(DESTDIR)$(ETCDIR)/rhnop - -uninstall: remove - -remove: $(REMOVE_TARGETS) - -remove-bin: - rm -f $(DESTDIR)$(BINDIR)/$(EXECUTABLE) - -remove-lib: - rm -f $(DESTDIR)$(LIBDIR)/conf.lua - rm -f $(DESTDIR)$(LIBDIR)/db.lua - -remove-etc: - -purge: remove - rm -rf $(DESTDIR)$(ETCDIR)/rhnop diff --git a/rhnop-client/conf.lua b/rhnop-client/conf.lua deleted file mode 100644 index a3adda6..0000000 --- a/rhnop-client/conf.lua +++ /dev/null @@ -1,33 +0,0 @@ --- --- rhnop --- --- Copyright (C) 2011-2014 Christian Pointner --- --- This file is part of rhnop. --- --- rhnop is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- any later version. --- --- rhnop is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with rhnop. If not, see . --- - -local conf = {} - -local file = assert(io.open(conffile, "r")) -for line in file:lines() do - local k,v = string.match(line, "^([^=#]+)=(.*)$") - if k and v and v ~= "" then - conf[k] = v - end -end -file:close() - -return conf diff --git a/rhnop-client/configure b/rhnop-client/configure deleted file mode 100755 index e64de0d..0000000 --- a/rhnop-client/configure +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/sh -# -# rhnop -# -# Copyright (C) 2011-2014 Christian Pointner -# -# This file is part of rhnop. -# -# rhnop is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# rhnop is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with rhnop. If not, see . -# - -EBUILD_COMPAT=0 - -PREFIX='/usr/local' -BINDIR='' -ETCDIR='' -LIBDIR='' - -print_usage() { - echo "configure --help print this" - echo " --prefix= the installation prefix (default: /usr/local)" - echo " --bindir= the path to the bin directory (default: $PREFIX/bin)" - echo " --sysconfdir= the path to the system configuration directory (default: $PREFIX/etc)" - echo " --libdir= the path to the lua library directory (default: $PREFIX/lib/rhnop-client)" -} - -for arg -do - case $arg in - --target=*) - TARGET=${arg#--target=} - ;; - --prefix=*) - PREFIX=${arg#--prefix=} - ;; - --bindir=*) - BINDIR=${arg#--bindir=} - ;; - --sysconfdir=*) - ETCDIR=${arg#--sysconfdir=} - ;; - --libdir=*) - LIBDIR=${arg#--libdir=} - ;; - --ebuild-compat) - EBUILD_COMPAT=1 - ;; - --help) - print_usage - exit 0 - ;; - *) - ERRORS="$ERRORS $arg" - ;; - esac -done - -if [ -n "$ERRORS" ] && [ $EBUILD_COMPAT -ne 1 ]; then - for error in $ERRORS; do - echo "Unknown argument: $error" - done - - print_usage - exit 1 -fi - -rm -f include.mk - -if [ -z "$BINDIR" ]; then - BINDIR=$PREFIX/bin -fi - -if [ -z "$ETCDIR" ]; then - ETCDIR=$PREFIX/etc -fi - -if [ -z "$LIBDIR" ]; then - LIBDIR=$PREFIX/lib/rhnop-client -fi - -cat > include.mk < --- --- This file is part of rhnop. --- --- rhnop is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- any later version. --- --- rhnop is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with rhnop. If not, see . --- - -luasql = require "luasql.mysql" - --- for destination database --- CREATE DATABASE nop CHARACTER SET utf8 COLLATE utf8_unicode_ci; --- GRANT select,insert,update,delete ON nop.master TO 'nopcollectd'@'localhost' IDENTIFIED BY ''; --- GRANT select,insert,update,delete ON nop.standby TO 'nopcollectd'@'localhost'; --- GRANT select,insert,update ON nop.state TO 'nopsysstated'@'localhost' IDENTIFIED BY ''; --- GRANT select ON nop.* TO 'nop'@'localhost' IDENTIFIED BY ''; --- USE nop --- CREATE TABLE IF NOT EXISTS master (timestamp BIGINT UNSIGNED PRIMARY KEY NOT NULL, cart INT NOT NULL, len INT, showtitle VARCHAR(255), title VARCHAR(255), artist VARCHAR(255), album VARCHAR(255), ismusic BOOLEAN); --- ALTER TABLE master CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; --- CREATE TABLE IF NOT EXISTS standby (timestamp BIGINT UNSIGNED PRIMARY KEY NOT NULL, cart INT NOT NULL, len INT, showtitle VARCHAR(255), title VARCHAR(255), artist VARCHAR(255), album VARCHAR(255), ismusic BOOLEAN); --- ALTER TABLE standby CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; --- CREATE TABLE IF NOT EXISTS state (timestamp BIGINT UNSIGNED PRIMARY KEY NOT NULL, state VARCHAR(32)); --- ALTER TABLE state CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; - -local db = {} - -function db.init(db, user, pwd, host, port, table) - local mydb = {} - - mydb.table = table - - local err - - mydb.env, err = luasql.mysql() - if mydb.env == nil then - return nil, err - end - - mydb.con, err = mydb.env:connect(db, user, pwd, host, port) - if mydb.con == nil then - return nil, err - end - - local ret, err = mydb.con:execute("SET CHARACTER SET utf8") - if ret == nil then - return nil, err - end - - ret, err = mydb.con:setautocommit(true) - if ret == nil then - return nil, err - end - - function mydb:getLastEntry() - local cur, err = self.con:execute("SELECT MAX(timestamp) FROM " .. self.table) - if cur == nil then - return nil, err - end - - local timestamp = cur:fetch() - if timestamp == nil then timestamp = 0 end - return timestamp - end - - function mydb:findMissingEntries(lasttimestamp) - local lastts = self.con:escape(lasttimestamp) - return self.con:execute("SELECT * FROM " .. self.table .. " WHERE timestamp > " .. lastts) - end - - function mydb:getNextMissingEntry(cur) - local data = {} - data = cur:fetch(data, "a") - if data == nil then - return nil, "that's all folks" - end - return data - end - - function mydb:getEntry(timestamp) - local ts = self.con:escape(timestamp) - local cur, err = self.con:execute("SELECT * FROM " .. self.table .. " WHERE timestamp = " .. ts) - if cur == nil then - return nil, err - end - - local data = {} - data = cur:fetch(data, "a") - if data == nil then - return nil, "nothing found" - end - return data - end - - function mydb:addEntry(data) - local timestamp = self.con:escape(data.timestamp) - local cart = self.con:escape(data.cart) - local len = self.con:escape(data.len) - local showtitle = self.con:escape(data.showtitle) - local title = self.con:escape(data.title) - local artist = self.con:escape(data.artist) - local album = self.con:escape(data.album) - local ismusic = self.con:escape(data.ismusic) - - local cur, err = self.con:execute("REPLACE INTO " .. self.table .. " VALUES('" .. timestamp .. "', '" .. cart .. "', '" .. len .. "', '" .. showtitle .. "', '" .. title .. "', '" .. artist .."', '" .. album .. "', '" .. ismusic .. "')") - if cur == nil then - return nil, err - end - - return true - end - - function mydb:getLastSysState() - local cur, err = self.con:execute("SELECT state FROM " .. self.table .. " WHERE timestamp = (SELECT MAX(timestamp) FROM " .. self.table .. ")") - if cur == nil then - return nil, err - end - - local state = cur:fetch() - if state == nil then state = "unknown" end - return state - end - - function mydb:updateSysState(timestamp, state) - local t = self.con:escape(timestamp) - local s = self.con:escape(state) - - local cur, err = self.con:execute("INSERT INTO " .. self.table .. " VALUES('" .. t .. "', '" .. s .. "')") - if cur == nil then - return nil, err - end - return true - end - - function mydb:close() - if self.con then - self.con:close() - end - - if self.env then - self.env:close() - end - end - - return mydb -end - -return db diff --git a/rhnop-client/debian/changelog b/rhnop-client/debian/changelog deleted file mode 100644 index 19e9bb3..0000000 --- a/rhnop-client/debian/changelog +++ /dev/null @@ -1,23 +0,0 @@ -rhnop-client (0.4) UNRELEASED; urgency=low - - * forcing utf-8 - - -- Christian Pointner Tue, 11 Mar 2014 16:01:08 +0100 - -rhnop-client (0.3) unstable; urgency=low - - * fixed error due to new luasql library version - - -- Christian Pointner Wed, 05 Mar 2014 18:20:46 +0100 - -rhnop-client (0.2) unstable; urgency=low - - * added nopsysstated - - -- Christian Pointner Wed, 5 Apr 2011 15:45:45 +0200 - -rhnop-client (0.1) unstable; urgency=low - - * Initial release. - - -- Christian Pointner Wed, 5 Apr 2011 02:16:41 +0200 diff --git a/rhnop-client/debian/compat b/rhnop-client/debian/compat deleted file mode 100644 index 7ed6ff8..0000000 --- a/rhnop-client/debian/compat +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/rhnop-client/debian/control b/rhnop-client/debian/control deleted file mode 100644 index e34f9b5..0000000 --- a/rhnop-client/debian/control +++ /dev/null @@ -1,15 +0,0 @@ -Source: rhnop-client -Section: interpreters -Priority: optional -Maintainer: Christian Pointner -Build-Depends: debhelper (>= 5), liblua5.1-0-dev, lua5.1 -Standards-Version: 3.8.2 -Homepage: http://www.helsinki.at/ - -Package: rhnop-client -Architecture: any -Depends: ${shlibs:Depends}, adduser, liblua5.1-socket2, liblua5.1-sql-mysql-2, lua5.1, runit -Description: Radio Helsinki now playing information system - client - The Radio Helsinki now playing information system gathers the - now playing info into an mysql database for further processing. - This package contains the client component. diff --git a/rhnop-client/debian/copyright b/rhnop-client/debian/copyright deleted file mode 100644 index 2ab2caa..0000000 --- a/rhnop-client/debian/copyright +++ /dev/null @@ -1,28 +0,0 @@ -This package was debianized by Christian Pointner on -Fri, 30 Mar 2011 11:23:42 +0200. - -Upstream Author: Christian Pointner - -Copyright: 2011-2014 Christian Pointner - -License: - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this package; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -On Debian systems, the complete text of the GNU General -Public License can be found in `/usr/share/common-licenses/GPL-3'. - -The Debian packaging is © 2009, Christian Pointner and -is licensed under the GPL, see above. diff --git a/rhnop-client/debian/postinst b/rhnop-client/debian/postinst deleted file mode 100755 index 3ff8b35..0000000 --- a/rhnop-client/debian/postinst +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# postinst script for rhnop-client - -set -e - -if [ "$1" = "configure" ]; then - adduser --quiet --system --group --no-create-home --home /var/run/rhnop rhnop - chgrp rhnop /etc/rhnop/nopcollectd.*.conf - chgrp rhnop /etc/rhnop/nopsysstated.conf -fi diff --git a/rhnop-client/debian/postrm b/rhnop-client/debian/postrm deleted file mode 100755 index eaf8334..0000000 --- a/rhnop-client/debian/postrm +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# postrm script for rhnop-client - -set -e - -if [ "$1" = "purge" ] ; then - if [ -x "$(command -v deluser)" -a -x "$(command -v delgroup)" ]; then - deluser --quiet --system rhnop || true - delgroup --quiet --system rhnop || true - else - echo "Not removing rhnop user and group: adduser package not found." >&2 - fi -fi diff --git a/rhnop-client/debian/rhnop-client.master.runit b/rhnop-client/debian/rhnop-client.master.runit deleted file mode 100644 index 69d7226..0000000 --- a/rhnop-client/debian/rhnop-client.master.runit +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -set -e - -exec 2>&1 -exec chpst -u rhnop:rhnop /usr/bin/nopcollectd master diff --git a/rhnop-client/debian/rhnop-client.master.runit.log b/rhnop-client/debian/rhnop-client.master.runit.log deleted file mode 100644 index 850066a..0000000 --- a/rhnop-client/debian/rhnop-client.master.runit.log +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -set -e - -LOG_D="/var/log/nopcollectd.master/" -if [ ! -d "$LOG_D" ]; then - mkdir -p -m0750 "$LOG_D" -fi -chown root:adm "$LOG_D" -exec chpst -u root:adm svlogd -tt "$LOG_D" diff --git a/rhnop-client/debian/rhnop-client.standby.runit b/rhnop-client/debian/rhnop-client.standby.runit deleted file mode 100644 index 01b7527..0000000 --- a/rhnop-client/debian/rhnop-client.standby.runit +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -set -e - -exec 2>&1 -exec chpst -u rhnop:rhnop /usr/bin/nopcollectd standby diff --git a/rhnop-client/debian/rhnop-client.standby.runit.log b/rhnop-client/debian/rhnop-client.standby.runit.log deleted file mode 100644 index 8223c28..0000000 --- a/rhnop-client/debian/rhnop-client.standby.runit.log +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -set -e - -LOG_D="/var/log/nopcollectd.standby/" -if [ ! -d "$LOG_D" ]; then - mkdir -p -m0750 "$LOG_D" -fi -chown root:adm "$LOG_D" -exec chpst -u root:adm svlogd -tt "$LOG_D" diff --git a/rhnop-client/debian/rhnop-client.state.runit b/rhnop-client/debian/rhnop-client.state.runit deleted file mode 100644 index f044abf..0000000 --- a/rhnop-client/debian/rhnop-client.state.runit +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -set -e - -exec 2>&1 -exec chpst -u rhnop:rhnop /usr/bin/nopsysstated diff --git a/rhnop-client/debian/rhnop-client.state.runit.log b/rhnop-client/debian/rhnop-client.state.runit.log deleted file mode 100644 index 7a67bb3..0000000 --- a/rhnop-client/debian/rhnop-client.state.runit.log +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -set -e - -LOG_D="/var/log/nopsysstated/" -if [ ! -d "$LOG_D" ]; then - mkdir -p -m0750 "$LOG_D" -fi -chown root:adm "$LOG_D" -exec chpst -u root:adm svlogd -tt "$LOG_D" diff --git a/rhnop-client/debian/rules b/rhnop-client/debian/rules deleted file mode 100755 index ef73f66..0000000 --- a/rhnop-client/debian/rules +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -configure: configure-stamp -configure-stamp: - dh_testdir - ./configure --prefix=/usr --sysconfdir=/etc - touch configure-stamp - -build: build-stamp - -build-stamp: configure-stamp - dh_testdir - $(MAKE) - touch $@ - -clean: - dh_testdir - dh_testroot - rm -f build-stamp configure-stamp - $(MAKE) distclean - dh_clean - -install: build - dh_testdir - dh_testroot - dh_installdirs - $(MAKE) DESTDIR=$(CURDIR)/debian/rhnop-client install - mkdir -p $(CURDIR)/debian/rhnop-client/etc/sv/rhnop-client.master/log - ln -s /var/run/sv.rhnop-client.master/ $(CURDIR)/debian/rhnop-client/etc/sv/rhnop-client.master/supervise - cp $(CURDIR)/debian/rhnop-client.master.runit $(CURDIR)/debian/rhnop-client/etc/sv/rhnop-client.master/run - ln -s /var/run/sv.rhnop-client.master.log/ $(CURDIR)/debian/rhnop-client/etc/sv/rhnop-client.master/log/supervise - cp $(CURDIR)/debian/rhnop-client.master.runit.log $(CURDIR)/debian/rhnop-client/etc/sv/rhnop-client.master/log/run - mkdir -p $(CURDIR)/debian/rhnop-client/etc/sv/rhnop-client.standby/log - ln -s /var/run/sv.rhnop-client.standby/ $(CURDIR)/debian/rhnop-client/etc/sv/rhnop-client.standby/supervise - cp $(CURDIR)/debian/rhnop-client.standby.runit $(CURDIR)/debian/rhnop-client/etc/sv/rhnop-client.standby/run - ln -s /var/run/sv.rhnop-client.standby.log/ $(CURDIR)/debian/rhnop-client/etc/sv/rhnop-client.standby/log/supervise - cp $(CURDIR)/debian/rhnop-client.standby.runit.log $(CURDIR)/debian/rhnop-client/etc/sv/rhnop-client.standby/log/run - mkdir -p $(CURDIR)/debian/rhnop-client/etc/sv/rhnop-client.state/log - ln -s /var/run/sv.rhnop-client.state/ $(CURDIR)/debian/rhnop-client/etc/sv/rhnop-client.state/supervise - cp $(CURDIR)/debian/rhnop-client.state.runit $(CURDIR)/debian/rhnop-client/etc/sv/rhnop-client.state/run - ln -s /var/run/sv.rhnop-client.state.log/ $(CURDIR)/debian/rhnop-client/etc/sv/rhnop-client.state/log/supervise - cp $(CURDIR)/debian/rhnop-client.state.runit.log $(CURDIR)/debian/rhnop-client/etc/sv/rhnop-client.state/log/run - -# Build architecture-independent files here. -binary-indep: install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: install - dh_testdir - dh_testroot - dh_installdocs - dh_installchangelogs - dh_installexamples - dh_link - dh_strip - dh_compress - dh_fixperms - chmod 640 debian/rhnop-client/etc/rhnop/nopcollectd.*.conf - chmod 640 debian/rhnop-client/etc/rhnop/nopsysstated.conf - chmod 755 debian/rhnop-client/etc/sv/rhnop-client.master/run - chmod 755 debian/rhnop-client/etc/sv/rhnop-client.master/log/run - chmod 755 debian/rhnop-client/etc/sv/rhnop-client.standby/run - chmod 755 debian/rhnop-client/etc/sv/rhnop-client.standby/log/run - chmod 755 debian/rhnop-client/etc/sv/rhnop-client.state/run - chmod 755 debian/rhnop-client/etc/sv/rhnop-client.state/log/run - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/rhnop-client/nopcollectd b/rhnop-client/nopcollectd deleted file mode 100755 index 0f7c66e..0000000 --- a/rhnop-client/nopcollectd +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/lua --- --- rhnop --- --- Copyright (C) 2011-2014 Christian Pointner --- --- This file is part of rhnop. --- --- rhnop is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- any later version. --- --- rhnop is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with rhnop. If not, see . --- --- --- send now and next cart# and length to nopsyncd --- this script should be called by the now/next macro cart --- the arguments should be: now# nowlen next# nextlen --- - -require "socket" - -package.path = package.path .. ";_rhnoplibdir_/?.lua" -db = require "db" - -if #arg < 1 then - io.stderr:write("too few parameters\n") - os.exit(1) -end - -conffile = "nopcollectd." .. arg[1] .. ".conf" -conf = require "conf" - -src_db = assert(db.init(conf.src_db, conf.src_user, conf.src_pwd, conf.src_host, conf.src_port, conf.src_table)) -dst_db = assert(db.init(conf.dst_db, conf.dst_user, conf.dst_pwd, conf.dst_host, conf.dst_port, conf.dst_table)) - -local sock = assert(socket.tcp()) -local ret, err = sock:connect(conf.sync_host, conf.sync_port) -if ret == nil then - print(err) - return 1 -end -print "connection established" - -local last = dst_db:getLastEntry() -print("last timestamp was " .. last) -local cur = assert(src_db:findMissingEntries(last)) -local cnt = 0 -while true do - local data = src_db:getNextMissingEntry(cur) - if data == nil then break end - local ret, err = dst_db:addEntry(data) - if ret == nil then print(err) end - cnt = cnt + 1 -end - -print("synced " .. cnt .. " Entries") - -while true do - local timestamp = sock:receive('*l') - if timestamp == nil then break end - data = assert(src_db:getEntry(timestamp)) - assert(dst_db:addEntry(data)) -end - -sock:close() - -return 0 diff --git a/rhnop-client/nopcollectd.master.conf b/rhnop-client/nopcollectd.master.conf deleted file mode 100644 index 5d61551..0000000 --- a/rhnop-client/nopcollectd.master.conf +++ /dev/null @@ -1,16 +0,0 @@ -sync_host=airplay.helsinki.at -sync_port=2345 - -src_db=rhnop -src_table=now -src_host=airplay.helsinki.at -#src_port=3306 -src_user=nopcollectd -src_pwd=123456 - -dst_db=nop -dst_table=master -dst_host=127.0.0.1 -#dst_port=3306 -dst_user=nopcollectd -dst_pwd=123456 diff --git a/rhnop-client/nopcollectd.standby.conf b/rhnop-client/nopcollectd.standby.conf deleted file mode 100644 index 92ba1aa..0000000 --- a/rhnop-client/nopcollectd.standby.conf +++ /dev/null @@ -1,16 +0,0 @@ -sync_host=airplay2.helsinki.at -sync_port=2345 - -src_db=rhnop -src_table=now -src_host=airplay2.helsinki.at -#src_port=3306 -src_user=nopcollectd -src_pwd=123456 - -dst_db=nop -dst_table=standby -dst_host=127.0.0.1 -#dst_port=3306 -dst_user=nopcollectd -dst_pwd=123456 diff --git a/rhnop-client/nopsysstated b/rhnop-client/nopsysstated deleted file mode 100755 index d303cbe..0000000 --- a/rhnop-client/nopsysstated +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/lua --- --- rhnop --- --- Copyright (C) 2011-2014 Christian Pointner --- --- This file is part of rhnop. --- --- rhnop is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- any later version. --- --- rhnop is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with rhnop. If not, see . --- --- --- send now and next cart# and length to nopsyncd --- this script should be called by the now/next macro cart --- the arguments should be: now# nowlen next# nextlen --- - -require "socket" - -package.path = package.path .. ";_rhnoplibdir_/?.lua" -db = require "db" - -conffile = "nopsysstated.conf" -conf = require "conf" - -db = assert(db.init(conf.db_db, conf.db_user, conf.db_pwd, conf.db_host, conf.db_port, conf.db_table)) - -local sock = assert(socket.tcp()) -local ret, err = sock:connect(conf.host, conf.port) -if ret == nil then - print(err) - return 1 -end -print "connection established" - -local current_state, err = db:getLastSysState() -if current_state == nil then - print(err) - return 1 -end -print("current state according to db is " .. current_state) - -while true do - local state = sock:receive('*l') - if state == nil then break end - if state ~= current_state then - -- reading timestamp (milliseconds since epoch) - local p = assert(io.popen("/bin/date --utc '+%s %N'" , 'r')) - local time = assert(p:read('*l')) - p:close() - local s, ns = assert(string.match(time, "([0-9]+) ([0-9]+)")) - local timestamp = s .. string.format("%06d", math.floor(ns/1000)) - - assert(db:updateSysState(timestamp, state)) - current_state = state - end -end - -sock:close() - -return 0 diff --git a/rhnop-client/nopsysstated.conf b/rhnop-client/nopsysstated.conf deleted file mode 100644 index b9892c8..0000000 --- a/rhnop-client/nopsysstated.conf +++ /dev/null @@ -1,9 +0,0 @@ -host=rhctl.helsinki.at -port=2345 - -db_db=nop -db_table=state -db_host=127.0.0.1 -#db_port=3306 -db_user=nopsysstated -db_pwd=123456 diff --git a/rhnop-server/Makefile b/rhnop-server/Makefile deleted file mode 100644 index 8435d2c..0000000 --- a/rhnop-server/Makefile +++ /dev/null @@ -1,110 +0,0 @@ -## -## rhnop -## -## Copyright (C) 2011-2014 Christian Pointner -## -## This file is part of rhnop. -## -## rhnop is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## any later version. -## -## rhnop is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with rhnop. If not, see . -## - -ifneq ($(MAKECMDGOALS),distclean) -include include.mk -endif - -EXECUTABLE := nopsyncd - -C_OBJS := l_pipe.o \ - nopsyncd.o - -C_SRCS := $(C_OBJS:%.o=%.c) - -.PHONY: clean distclean install install-bin install-etc uninstall remove purge - -all: $(EXECUTABLE) - -%.d: %.c - @set -e; rm -f $@; \ - $(CC) -MM $(CFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$; echo '(re)building $@' - -ifneq ($(MAKECMDGOALS),distclean) --include $(C_SRCS:%.c=%.d) -endif - -$(EXECUTABLE): $(C_OBJS) - $(CC) $(C_OBJS) -o $@ $(LDFLAGS) - -%.o: %.c - $(CC) $(CFLAGS) -c $< - -strip: $(EXECUTABLE) - $(STRIP) -s $(EXECUTABLE) - - -distclean: clean - find . -name *.o -exec rm -f {} \; - find . -name "*.\~*" -exec rm -rf {} \; - rm -f include.mk - rm -f config.h - -clean: - rm -f *.o - rm -f *.d - rm -f *.d.* - rm -f $(EXECUTABLE) - -INSTALL_TARGETS := install-bin install-lib install-etc -REMOVE_TARGETS := remove-bin remove-lib remove-etc - -install: all $(INSTALL_TARGETS) - -install-bin: $(EXECUTABLE) - $(INSTALL) -d $(DESTDIR)$(BINDIR) - $(INSTALL) -m 755 $(EXECUTABLE) $(DESTDIR)$(BINDIR) - $(INSTALL) -m 755 noprml $(DESTDIR)$(BINDIR) - -install-lib: - $(INSTALL) -d $(DESTDIR)$(LIBDIR) - $(INSTALL) -m 644 conf.lua $(DESTDIR)$(LIBDIR) - $(SED) -e 's#^local filename.*$$#local filename = "$(ETCDIR)/rhnop/nopsyncd.conf"#' -i $(DESTDIR)$(LIBDIR)/conf.lua - $(INSTALL) -m 644 playlog.lua $(DESTDIR)$(LIBDIR) - $(INSTALL) -m 644 rddb.lua $(DESTDIR)$(LIBDIR) - $(INSTALL) -m 644 qlistener.lua $(DESTDIR)$(LIBDIR) - $(INSTALL) -m 644 tcpserver.lua $(DESTDIR)$(LIBDIR) - -install-etc: - $(INSTALL) -d $(DESTDIR)$(ETCDIR)/rhnop - $(INSTALL) -m 640 nopsyncd.conf $(DESTDIR)$(ETCDIR)/rhnop - -uninstall: remove - -remove: $(REMOVE_TARGETS) - -remove-bin: - rm -f $(DESTDIR)$(BINDIR)/$(EXECUTABLE) - rm -f $(DESTDIR)$(BINDIR)/noprml - -remove-lib: - rm -f $(DESTDIR)$(LIBDIR)/conf.lua - rm -f $(DESTDIR)$(LIBDIR)/playlog.lua - rm -f $(DESTDIR)$(LIBDIR)/rddb.lua - rm -f $(DESTDIR)$(LIBDIR)/qlistener.lua - rm -f $(DESTDIR)$(LIBDIR)/tcpserver.lua - -remove-etc: - -purge: remove - rm -rf $(DESTDIR)$(ETCDIR)/rhnop diff --git a/rhnop-server/conf.lua b/rhnop-server/conf.lua deleted file mode 100644 index 8294df6..0000000 --- a/rhnop-server/conf.lua +++ /dev/null @@ -1,44 +0,0 @@ --- --- rhnop --- --- Copyright (C) 2011-2014 Christian Pointner --- --- This file is part of rhnop. --- --- rhnop is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- any later version. --- --- rhnop is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with rhnop. If not, see . --- - -local conf = {} - -local filename = "nopsyncd.conf" - -local file = assert(io.open(filename, "r")) -for line in file:lines() do - local k,v = string.match(line, "^([^=#]+)=(.*)$") - if k and v and v ~= "" then - conf[k] = v - end -end -file:close() - -if conf.music_carts_lo == nil then - conf.music_carts_lo = 400000 -end -if conf.music_carts_hi == nil then - conf.music_carts_hi = 499999 -end -conf.music_carts_lo = tonumber(conf.music_carts_lo) -conf.music_carts_hi = tonumber(conf.music_carts_hi) - -return conf diff --git a/rhnop-server/configure b/rhnop-server/configure deleted file mode 100755 index 42f5435..0000000 --- a/rhnop-server/configure +++ /dev/null @@ -1,223 +0,0 @@ -#!/bin/sh -# -# rhnop -# -# Copyright (C) 2011-2014 Christian Pointner -# -# This file is part of rhnop. -# -# rhnop is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# rhnop is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with rhnop. If not, see . -# - -TARGET=`uname -s` -EBUILD_COMPAT=0 - -CFLAGS='-g -O2' -LDFLAGS='-g -Wall -O2 -lpthread' - -LUA_DIR='' -LUA='' - -PREFIX='/usr/local' -BINDIR='' -ETCDIR='' -LIBDIR='' - -print_usage() { - echo "configure --help print this" - echo " --target= build target i.e. Linux (default: autodetect)" - echo " --prefix= the installation prefix (default: /usr/local)" - echo " --bindir= the path to the bin directory (default: $PREFIX/bin)" - echo " --sysconfdir= the path to the system configuration directory (default: $PREFIX/etc)" - echo " --libdir= the path to the lua library directory (default: $PREFIX/lib/rhnop-server)" - echo " --with-lua= use this lua tree instead of system default" -} - -for arg -do - case $arg in - --target=*) - TARGET=${arg#--target=} - ;; - --prefix=*) - PREFIX=${arg#--prefix=} - ;; - --bindir=*) - BINDIR=${arg#--bindir=} - ;; - --sysconfdir=*) - ETCDIR=${arg#--sysconfdir=} - ;; - --libdir=*) - LIBDIR=${arg#--libdir=} - ;; - --with-lua=*) - LUA_DIR=${arg#--with-lua=} - ;; - --ebuild-compat) - EBUILD_COMPAT=1 - ;; - --help) - print_usage - exit 0 - ;; - *) - ERRORS="$ERRORS $arg" - ;; - esac -done - -if [ -n "$ERRORS" ] && [ $EBUILD_COMPAT -ne 1 ]; then - for error in $ERRORS; do - echo "Unknown argument: $error" - done - - print_usage - exit 1 -fi - -rm -f config.h -rm -f include.mk -case $TARGET in - Linux) - LDFLAGS=$LDFLAGS' -ldl' - ;; - *) - echo "platform not supported" - exit 1; - ;; -esac - - -test_lua_version() -{ - LUA_VERSION=`cat $1 | grep "#define LUA_VERSION[ ]" | cut -f2- | tr -d '"' | sed -e 's/Lua \([0-9][0-9.]*\)/\1/'` - LUA_VERSION_NUM=`cat $1 | grep "#define LUA_VERSION_NUM" | awk '{ print $3 }'` - LUA_RELEASE=`cat $1 | grep "#define LUA_RELEASE[ ]" | cut -f2-` - - if [ $LUA_VERSION_NUM -ge 501 ]; then - return 1; - else - return 0; - fi -} - -if [ -z "$LUA_DIR" ]; then - for prefix in /usr /usr/local; do - if [ -e $prefix/include/lua.h ]; then - test_lua_version $prefix/include/lua.h - if [ $? -eq 1 ]; then - echo "using Lua $LUA_VERSION ($LUA_RELEASE) found at $prefix/include" - CFLAGS="$CFLAGS -I'$prefix/include'" - LDFLAGS="$LDFLAGS -L'$prefix/lib' -llua" - LUA=$prefix/lua - LUAC=$prefix/luac - break - fi - else - for dir in `ls -d $prefix/include/lua* 2> /dev/null`; do - if [ -e $dir/lua.h ]; then - test_lua_version $dir/lua.h - if [ $? -eq 1 ]; then - echo "using Lua $LUA_VERSION ($LUA_RELEASE) found at $dir" - CFLAGS="$CFLAGS -I$dir" - if [ -x "$prefix/bin/lua$LUA_VERSION" ]; then - LDFLAGS="$LDFLAGS -L'$prefix/lib' -llua$LUA_VERSION" - LUA=$prefix/bin/lua$LUA_VERSION - LUAC=$prefix/bin/luac$LUA_VERSION - elif [ -x "$prefix/bin/lua-$LUA_VERSION" ]; then - LDFLAGS="$LDFLAGS -L'$prefix/lib' -llua-$LUA_VERSION" - LUA=$prefix/bin/lua-$LUA_VERSION - LUAC=$prefix/bin/luac-$LUA_VERSION - else - echo "ERROR: found lua.h at $dir/lua.h but no matching lua and luac" - return 1 - fi - break - fi - fi - done - if [ -n "$LUAC" ]; then - break - fi - fi - done - - if [ -z "$LUAC" ]; then - echo "ERROR: no suitable lua found .. please install lua 5.1 or higher or use --with-lua" - return 1 - fi - -else - CFLAGS="$CFLAGS -I'$LUA_DIR/include'" - LDFLAGS="$LDFLAGS '$LUA_DIR/lib/liblua.a'" - LUA=$LUA_DIR/bin/lua - LUAC=$LUA_DIR/bin/luac -fi - -if [ -z "$BINDIR" ]; then - BINDIR=$PREFIX/bin -fi - -if [ -z "$ETCDIR" ]; then - ETCDIR=$PREFIX/etc -fi - -if [ -z "$LIBDIR" ]; then - LIBDIR=$PREFIX/lib/rhnop-server -fi - -cat > include.mk < config.h < Tue, 11 Mar 2014 16:46:13 +0100 - -rhnop-server (0.9) unstable; urgency=low - - * fixed error due to new luasql library version - - -- Christian Pointner Wed, 05 Mar 2014 19:28:44 +0100 - -rhnop-server (0.8) unstable; urgency=low - - * fixed runit script. - * added log services to runit. - * switched to microsends for timestamp. - - -- Christian Pointner Wed, 02 Apr 2011 17:53:25 +0200 - -rhnop-server (0.7) unstable; urgency=low - - * fixed utf-8 handling. - * changed to bigint for timestamp. - - -- Christian Pointner Wed, 31 Mar 2011 20:39:52 +0200 - -rhnop-server (0.6) unstable; urgency=low - - * fixed handling of invalid carts. - - -- Christian Pointner Wed, 30 Mar 2011 19:36:22 +0200 - -rhnop-server (0.5) unstable; urgency=low - - * better handling of invalid carts. - - -- Christian Pointner Wed, 30 Mar 2011 19:35:22 +0200 - -rhnop-server (0.4) unstable; urgency=low - - * noprml ignores dummy carts now. - - -- Christian Pointner Wed, 30 Mar 2011 18:35:22 +0200 - -rhnop-server (0.3) unstable; urgency=low - - * some cleanup. - - -- Christian Pointner Wed, 30 Mar 2011 17:32:21 +0200 - -rhnop-server (0.2) unstable; urgency=low - - * added runit init scrip. - - -- Christian Pointner Wed, 30 Mar 2011 16:34:24 +0200 - -rhnop-server (0.1) unstable; urgency=low - - * Initial release. - - -- Christian Pointner Wed, 30 Mar 2011 13:50:41 +0200 diff --git a/rhnop-server/debian/compat b/rhnop-server/debian/compat deleted file mode 100644 index 7ed6ff8..0000000 --- a/rhnop-server/debian/compat +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/rhnop-server/debian/control b/rhnop-server/debian/control deleted file mode 100644 index 97b440e..0000000 --- a/rhnop-server/debian/control +++ /dev/null @@ -1,15 +0,0 @@ -Source: rhnop-server -Section: interpreters -Priority: optional -Maintainer: Christian Pointner -Build-Depends: debhelper (>= 5), liblua5.1-0-dev, lua5.1 -Standards-Version: 3.8.2 -Homepage: http://www.helsinki.at/ - -Package: rhnop-server -Architecture: any -Depends: ${shlibs:Depends}, adduser, liblua5.1-mq, liblua5.1-socket2, liblua5.1-sql-mysql-2, liblua5.1-posix1, lua5.1, runit -Description: Radio Helsinki now playing information system - server - The Radio Helsinki now playing information system gathers the - now playing info into an mysql database for further processing. - This package contains the server component (rivendell side). \ No newline at end of file diff --git a/rhnop-server/debian/copyright b/rhnop-server/debian/copyright deleted file mode 100644 index 2ab2caa..0000000 --- a/rhnop-server/debian/copyright +++ /dev/null @@ -1,28 +0,0 @@ -This package was debianized by Christian Pointner on -Fri, 30 Mar 2011 11:23:42 +0200. - -Upstream Author: Christian Pointner - -Copyright: 2011-2014 Christian Pointner - -License: - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this package; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -On Debian systems, the complete text of the GNU General -Public License can be found in `/usr/share/common-licenses/GPL-3'. - -The Debian packaging is © 2009, Christian Pointner and -is licensed under the GPL, see above. diff --git a/rhnop-server/debian/postinst b/rhnop-server/debian/postinst deleted file mode 100755 index 4b5c141..0000000 --- a/rhnop-server/debian/postinst +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# postinst script for rhnop-server - -set -e - -if [ "$1" = "configure" ]; then - adduser --quiet --system --group --no-create-home --home /var/run/rhnop rhnop - chgrp rhnop /etc/rhnop/nopsyncd.conf -fi diff --git a/rhnop-server/debian/postrm b/rhnop-server/debian/postrm deleted file mode 100755 index 18cb882..0000000 --- a/rhnop-server/debian/postrm +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# postrm script for rhnop-server - -set -e - -if [ "$1" = "purge" ] ; then - if [ -x "$(command -v deluser)" -a -x "$(command -v delgroup)" ]; then - deluser --quiet --system rhnop || true - delgroup --quiet --system rhnop || true - else - echo "Not removing rhnop user and group: adduser package not found." >&2 - fi -fi diff --git a/rhnop-server/debian/rhnop-server.runit b/rhnop-server/debian/rhnop-server.runit deleted file mode 100644 index 37b0795..0000000 --- a/rhnop-server/debian/rhnop-server.runit +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -set -e - -exec 2>&1 -exec chpst -u rhnop:rhnop /usr/bin/nopsyncd diff --git a/rhnop-server/debian/rhnop-server.runit.log b/rhnop-server/debian/rhnop-server.runit.log deleted file mode 100644 index a8766ea..0000000 --- a/rhnop-server/debian/rhnop-server.runit.log +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -set -e - -LOG_D="/var/log/nopsyncd/" -if [ ! -d "$LOG_D" ]; then - mkdir -p -m0750 "$LOG_D" -fi -chown root:adm "$LOG_D" -exec chpst -u root:adm svlogd -tt "$LOG_D" diff --git a/rhnop-server/debian/rules b/rhnop-server/debian/rules deleted file mode 100755 index ac5d9fc..0000000 --- a/rhnop-server/debian/rules +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -configure: configure-stamp -configure-stamp: - dh_testdir - ./configure --prefix=/usr --sysconfdir=/etc - touch configure-stamp - -build: build-stamp - -build-stamp: configure-stamp - dh_testdir - $(MAKE) - touch $@ - -clean: - dh_testdir - dh_testroot - rm -f build-stamp configure-stamp - $(MAKE) distclean - dh_clean - -install: build - dh_testdir - dh_testroot - dh_installdirs - $(MAKE) DESTDIR=$(CURDIR)/debian/rhnop-server install - mkdir -p $(CURDIR)/debian/rhnop-server/etc/sv/rhnop-server/log - ln -s /var/run/sv.rhnop-server/ $(CURDIR)/debian/rhnop-server/etc/sv/rhnop-server/supervise - cp $(CURDIR)/debian/rhnop-server.runit $(CURDIR)/debian/rhnop-server/etc/sv/rhnop-server/run - ln -s /var/run/sv.rhnop-server.log/ $(CURDIR)/debian/rhnop-server/etc/sv/rhnop-server/log/supervise - cp $(CURDIR)/debian/rhnop-server.runit.log $(CURDIR)/debian/rhnop-server/etc/sv/rhnop-server/log/run - -# Build architecture-independent files here. -binary-indep: install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: install - dh_testdir - dh_testroot - dh_installdocs - dh_installchangelogs - dh_installexamples - dh_link - dh_strip - dh_compress - dh_fixperms - chmod 640 debian/rhnop-server/etc/rhnop/nopsyncd.conf - chmod 755 debian/rhnop-server/etc/sv/rhnop-server/run - chmod 755 debian/rhnop-server/etc/sv/rhnop-server/log/run - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/rhnop-server/l_pipe.c b/rhnop-server/l_pipe.c deleted file mode 100644 index 1cd8e49..0000000 --- a/rhnop-server/l_pipe.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * rhnop - * - * Copyright (C) 2011-2014 Christian Pointner - * - * This file is part of rhnop. - * - * rhnop is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * rhnop is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with rhnop. If not, see . - */ - -#include -#include - -#include -#include -#include - -#include "l_pipe.h" - -static int pipefds_[2]; - -int pipe_init() -{ - return pipe(pipefds_); -} - -void pipe_close() -{ - close(pipefds_[0]); - close(pipefds_[1]); -} - -static int l_pipe_signal(lua_State *L) -{ - size_t len = 0, written = 0; - const char* data = luaL_checklstring(L, 1, &len); - len++; // also send trailing zero - - int ret = 0; - for(;;) { - ret = write(pipefds_[1], &(data[written]), len - written); - if(!ret) continue; - if(ret == -1 && (errno == EAGAIN || errno == EINTR)) continue; - - written += ret; - if(written == len) break; - - break; - } - - lua_pushinteger(L, ret); - return 1; -} - -static int l_pipe_getfd(lua_State *L) -{ - if(!lua_istable(L, -1)) - luaL_error(L, "can't retreive pipe fd"); - - lua_pushliteral(L, "fd"); - lua_gettable(L, -2); - return 1; -} - -static int l_pipe_dirty(lua_State *L) -{ - lua_pushboolean(L, 0); - return 1; -} - -static int l_pipe_getreadfd(lua_State *L) -{ - lua_newtable(L); - lua_pushliteral(L, "fd"); - lua_pushinteger(L, pipefds_[0]); - lua_settable(L, -3); - lua_pushliteral(L, "getfd"); - lua_pushcfunction(L, l_pipe_getfd); - lua_settable(L, -3); - lua_pushliteral(L, "dirty"); - lua_pushcfunction(L, l_pipe_dirty); - lua_settable(L, -3); - return 1; -} - -static int l_pipe_consume(lua_State *L) -{ - char data[17]; // 17 should be sufficient - size_t len = 0; - - int ret = 0; - for(;;) { - ret = read(pipefds_[0], &(data[len]), 1); - if(ret == 0) break; - if(ret == -1 && (errno == EAGAIN || errno == EINTR)) continue; - - if(data[len] == 0) - break; - - len += ret; - if(len >= sizeof(data)) { - ret = 0; - break; - } - } - - if(ret) - lua_pushstring(L, data); - else - lua_pushnil(L); - - return 1; -} - -static const struct luaL_reg pipe_funcs [] = { - { "signal", l_pipe_signal }, - { "getreadfd", l_pipe_getreadfd }, - { "consume", l_pipe_consume }, - { NULL, NULL } -}; - -LUALIB_API int luaopen_pipe(lua_State *L) -{ - luaL_register(L, LUA_PIPELIBNAME, pipe_funcs); - return 1; -} diff --git a/rhnop-server/l_pipe.h b/rhnop-server/l_pipe.h deleted file mode 100644 index ee3a424..0000000 --- a/rhnop-server/l_pipe.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * rhnop - * - * Copyright (C) 2011-2014 Christian Pointner - * - * This file is part of rhnop. - * - * rhnop is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * rhnop is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with rhnop. If not, see . - */ - -#ifndef NOPSYNCD_l_pipe_h_INCLUDED -#define NOPSYNCD_l_pipe_h_INCLUDED - -#include - -int pipe_init(); -void pipe_close(); - -#define LUA_PIPELIBNAME "pipe" -LUALIB_API int luaopen_pipe(lua_State *L); - -#endif diff --git a/rhnop-server/noprml b/rhnop-server/noprml deleted file mode 100755 index cb9ddce..0000000 --- a/rhnop-server/noprml +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/lua --- --- rhnop --- --- Copyright (C) 2011-2014 Christian Pointner --- --- This file is part of rhnop. --- --- rhnop is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- any later version. --- --- rhnop is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with rhnop. If not, see . --- --- --- send now and next cart# and length to nopsyncd --- this script should be called by the now/next macro cart --- the arguments should be: now# nowlen next# nextlen --- - -local queue_name = "/rhnop" - --- reading timestamp (milliseconds since epoch) -local p = assert(io.popen("/bin/date --utc '+%s %N'" , 'r')) -local time = assert(p:read('*l')) -p:close() -local s, ns = assert(string.match(time, "([0-9]+) ([0-9]+)")) -local timestamp = s .. string.format("%06d", math.floor(ns/1000)) - --- check arguments -if #arg < 4 then - io.stderr:write("too few parameters\n") - os.exit(1) -end - -require "posix" -mq = require "mq" - --- open message queue -posix.umask("rwxrwxr-x") -local q, err = mq.create(queue_name, "wo", "rw-rw----") -if q == nil then - q, err = mq.open(queue_name, "wo") - if q == nil then - io.stderr:write("creation of message queue failed: " .. err .. "\n") - os.exit(1) - end -end - --- send out message to nopsyncd -local result, err = mq.send(q, timestamp .. " " .. arg[1] .. " " .. arg[2] .. " " .. arg[3] .. " " .. arg[4], 0) -if result == nil then - io.stderr:write("sending message failed: " .. err .. "\n") - os.exit(2) -end - -mq.close(q) diff --git a/rhnop-server/nopsyncd.c b/rhnop-server/nopsyncd.c deleted file mode 100644 index 35558c2..0000000 --- a/rhnop-server/nopsyncd.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - * rhnop - * - * Copyright (C) 2011-2014 Christian Pointner - * - * This file is part of rhnop. - * - * rhnop is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * rhnop is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with rhnop. If not, see . - */ - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "l_pipe.h" -#include "config.h" - -#define LUA_MAIN_LOOP_FUNC "main_loop" -#define QLISTENER LIBDIR"/qlistener.lua" -#define TCPSERVER LIBDIR"/tcpserver.lua" - -static const luaL_Reg nopsyncd_lualibs[] = { - {"", luaopen_base}, - {LUA_LOADLIBNAME, luaopen_package}, - {LUA_TABLIBNAME, luaopen_table}, - {LUA_STRLIBNAME, luaopen_string}, - {LUA_MATHLIBNAME, luaopen_math}, - {LUA_IOLIBNAME, luaopen_io}, - {LUA_OSLIBNAME, luaopen_os}, - {LUA_PIPELIBNAME, luaopen_pipe}, - {NULL, NULL} -}; - -int init_main_loop(lua_State *L, const char* filename) -{ - const luaL_Reg *lib = nopsyncd_lualibs; - for (; lib->func; lib++) { - lua_pushcfunction(L, lib->func); - lua_pushstring(L, lib->name); - lua_call(L, 1, 0); - } - - int ret = luaL_loadfile(L, filename); - if(ret) { - const char* err_str = luaL_checkstring(L, -1); - switch(ret) { - case LUA_ERRSYNTAX: fprintf(stderr, "luaL_loadfile() syntax error: %s\n", err_str); break; - case LUA_ERRMEM: fprintf(stderr, "luaL_loadfile() malloc error: %s\n", err_str); break; - case LUA_ERRFILE: fprintf(stderr, "lauL_loadfile() error: %s\n", err_str); break; - default: fprintf(stderr, "luaL_loadfile() unknown error: %s\n", err_str); break; - } - return -1; - } - - lua_pushstring(L, LIBDIR); - lua_setglobal(L, "rhnoplibdir"); - - ret = lua_pcall(L, 0, 0, 0); - if(ret) { - const char* err_str = luaL_checkstring(L, -1); - switch(ret) { - case LUA_ERRRUN: fprintf(stderr, "lua_pcall() runtime error: %s\n", err_str); break; - case LUA_ERRMEM: fprintf(stderr, "lua_pcall() malloc error: %s\n", err_str); break; - case LUA_ERRERR: fprintf(stderr, "lua_pcall() error at error handler function: %s\n", err_str); break; - } - return -1; - } - - return 0; -} - -int call_main_loop(lua_State* L, const char* filename) -{ - lua_getglobal(L, LUA_MAIN_LOOP_FUNC); - if(!lua_isfunction(L, -1)) { - fprintf(stderr, "there is no function '%s' at file '%s'\n", LUA_MAIN_LOOP_FUNC, filename); - return -1; - }; - - int ret = lua_pcall(L, 0, 1, 0); - if(ret) { - const char* err_str = luaL_checkstring(L, -1); - switch(ret) { - case LUA_ERRRUN: fprintf(stderr, "lua_pcall(%s:%s) runtime error: %s\n", filename, LUA_MAIN_LOOP_FUNC, err_str); break; - case LUA_ERRMEM: fprintf(stderr, "lua_pcall(%s:%s) malloc error: %s\n", filename, LUA_MAIN_LOOP_FUNC, err_str); break; - case LUA_ERRERR: fprintf(stderr, "lua_pcall(%s:%s) error at error handler function: %s\n", filename, LUA_MAIN_LOOP_FUNC, err_str); break; - } - return -1; - } - - ret = lua_tointeger(L, 1); - return ret; -} - -void* main_loop(void* file) -{ - if(!file) - pthread_exit(NULL); - - - lua_State *L; - L = luaL_newstate(); - if(!L) { - fprintf(stderr, "error creating lua state\n"); - pthread_exit(NULL); - } - - int ret = init_main_loop(L, (char*)file); - if(!ret) - ret = call_main_loop(L, (char*)file); - - printf("%s returned with %d\n", (char*)file, ret); - - lua_close(L); - - /* this should bring down the other thread as well - at least this is true for the tcp-server thread */ - pipe_close(); - - pthread_exit(NULL); -} - -int main(int argc, char* argv[]) -{ - printf("starting nopsyncd...\n"); - - pthread_t qlistener, tcpserver; - - int ret = pipe_init(); - if(ret) { - fprintf(stderr, "Error creating pipe: %s\n", strerror(errno)); - return 1; - } - - ret = pthread_create(&qlistener, NULL, main_loop, QLISTENER); - if(ret) { - fprintf(stderr, "Error creating qlistener thread (code: %d)\n", ret); - return 1; - } - pthread_detach(qlistener); /* can't kill this thread so don't join to it */ - - ret = pthread_create(&tcpserver, NULL, main_loop, TCPSERVER); - if(ret) { - fprintf(stderr, "Error creating tcpserver thread (code: %d)\n", ret); - return 1; - } - -/* this thread can't be cancelled so don't wait for it */ -/* pthread_join(qlistener, NULL); */ - pthread_join(tcpserver, NULL); - - printf("stopping nopsyncd.\n"); - return 0; -} diff --git a/rhnop-server/nopsyncd.conf b/rhnop-server/nopsyncd.conf deleted file mode 100644 index a80d620..0000000 --- a/rhnop-server/nopsyncd.conf +++ /dev/null @@ -1,18 +0,0 @@ -queue_name=/rhnop -tcp_host=* -tcp_port=2345 - -music_carts_lo=400000 -music_carts_hi=499999 - -rddb_db=rivendell -rddb_host=127.0.0.1 -#rddb_port=3306 -rddb_user= -rddb_pwd= - -playlog_db=rhnop -playlog_host=127.0.0.1 -#playlog_port=3306 -playlog_user= -playlog_pwd= diff --git a/rhnop-server/playlog.lua b/rhnop-server/playlog.lua deleted file mode 100644 index 591ee6b..0000000 --- a/rhnop-server/playlog.lua +++ /dev/null @@ -1,98 +0,0 @@ --- --- rhnop --- --- Copyright (C) 2011-2014 Christian Pointner --- --- This file is part of rhnop. --- --- rhnop is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- any later version. --- --- rhnop is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with rhnop. If not, see . --- - -luasql = require "luasql.mysql" - --- CREATE DATABASE rhnop CHARACTER SET utf8 COLLATE utf8_unicode_ci; --- GRANT select,insert,update ON rhnop.* TO 'nopsyncd' IDENTIFIED BY ''; --- GRANT select ON rhnop.* TO 'nopcollectd' IDENTIFIED BY ''; --- USE rhnop --- CREATE TABLE IF NOT EXISTS now (timestamp BIGINT UNSIGNED PRIMARY KEY NOT NULL, cart INT NOT NULL, len INT, showtitle VARCHAR(255), title VARCHAR(255), artist VARCHAR(255), album VARCHAR(255), ismusic BOOLEAN); --- ALTER TABLE now CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; - -conf = require "conf" - -local playlog = {} - -function playlog:init() - local err - - self.env, err = luasql.mysql() - if self.env == nil then - return nil, err - end - - self.con, err = self.env:connect(conf.playlog_db, conf.playlog_user, conf.playlog_pwd, conf.playlog_host, conf.playlog_port) - if self.con == nil then - return nil, err - end - - local ret, err = self.con:execute("SET CHARACTER SET utf8") - if ret == nil then - return nil, err - end - - ret, err = self.con:setautocommit(true) - if ret == nil then - return nil, err - end - - return true -end - -function playlog:getLastCart() - local cur, err = self.con:execute("SELECT cart FROM now WHERE timestamp = (SELECT MAX(timestamp) FROM now)") - if cur == nil then - return nil, err - end - - local cart = cur:fetch() - if cart == nil then cart = 0 end - return cart -end - -function playlog:insertNowMusic(timestamp, cart, len, title, artist, album) - cart = tonumber(cart) - len = tonumber(len) - if cart < 400000 or cart > 450000 then - poolnum = 0 - else - poolnum = math.floor(cart/1000) - 399 - end - local cur, err = self.con:execute("INSERT into now VALUES(" .. self.con:escape(timestamp) .. ", " .. cart .. ", " .. len .. ", 'Musikpool " .. poolnum .. "', '" .. self.con:escape(title) .. "', '" .. self.con:escape(artist) .."', '" .. self.con:escape(album) .. "', 1)") - if cur == nil then - return nil, err - end - - return true -end - -function playlog:close() - if self.con then - self.con:close() - end - - if self.env then - self.env:close() - end -end - -return playlog diff --git a/rhnop-server/qlistener.lua b/rhnop-server/qlistener.lua deleted file mode 100644 index b41e2a7..0000000 --- a/rhnop-server/qlistener.lua +++ /dev/null @@ -1,98 +0,0 @@ --- --- rhnop --- --- Copyright (C) 2011-2014 Christian Pointner --- --- This file is part of rhnop. --- --- rhnop is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- any later version. --- --- rhnop is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with rhnop. If not, see . --- - -local last_cart = nil - -require "posix" -mq = require "mq" - -package.path = package.path .. ";" .. rhnoplibdir .. "/?.lua" -playlog = require "playlog" -rddb = require "rddb" -conf = require "conf" - -function handle_now(timestamp, nowcart, nowlen) - local results, err = rddb:getCartInfo(nowcart); - if results == nil then - io.stderr:write("can't fetch cart info: " .. err .. "\n") --- TODO: this error shouldn't be ignored!!!! - else --- print(timestamp .. " Info: '" .. results.TITLE .. "' von '" .. results.ARTIST .. "' aus '" .. results.ALBUM .. "'") - local ret, err = playlog:insertNowMusic(timestamp, nowcart, nowlen, results.TITLE, results.ARTIST, results.ALBUM) - if ret == nil then - io.stderr:write("can't insert music info: " .. err .. "\n") - else - pipe.signal(timestamp) - end - end -end - -function handle_message(msg) - local timestamp, nowcart, nowlen, nextcart, nextlen = string.match(msg, "^(%d+) (%d+) (%d+) (%d+) (%d+)$"); - if not timestamp or not nowcart or not nowlen or not nextcart or not nextlen then - io.stderr:write("ignoring malformed message\n") - else - nowcart = tonumber(nowcart) - nowlen = tonumber(nowlen) - if last_cart ~= nowcart and nowcart >= conf.music_carts_lo and nowcart <= conf.music_carts_hi and nowlen > 0 then - last_cart = nowcart - handle_now(timestamp, nowcart, nowlen) - end - -- TODO handle next info - end -end - -function main_loop() - posix.umask("rwxrwxr-x") - local q, err = mq.create(conf.queue_name, "ro", "rw-rw----") - if q == nil then - q, err = mq.open(conf.queue_name, "wo") - if q == nil then - io.stderr:write("creation of message queue failed: " .. err .. "\n") - os.exit(1) - end - end - - local ret, err = playlog:init() - if ret == nil then - io.stderr:write("creation of playlog failed: " .. err .. "\n") - os.exit(1) - end - last_cart = assert(playlog:getLastCart()) - - local ret, err = rddb:init() - if ret == nil then - io.stderr:write("opening rivendell db failed: " .. err .. "\n") - playlog:close() - os.exit(1) - end - - while true do - local msg, prio = mq.receive(q) - if msg == nil then - io.stderr:write("recv error: " .. prio .. "\n") - rddb:close() - playlog:close() - os.exit(2) - end - handle_message(msg) - end -end diff --git a/rhnop-server/rddb.lua b/rhnop-server/rddb.lua deleted file mode 100644 index 9626632..0000000 --- a/rhnop-server/rddb.lua +++ /dev/null @@ -1,80 +0,0 @@ --- --- rhnop --- --- Copyright (C) 2011-2014 Christian Pointner --- --- This file is part of rhnop. --- --- rhnop is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- any later version. --- --- rhnop is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with rhnop. If not, see . --- - -luasql = require "luasql.mysql" - -conf = require "conf" - -local rddb = {} - -function rddb:init() - local err - - self.env, err = luasql.mysql() - if self.env == nil then - return nil, err - end - - self.con, err = self.env:connect(conf.rddb_db, conf.rddb_user, conf.rddb_pwd, conf.rddb_host, conf.rddb_port) - if self.con == nil then - return nil, err - end - - local ret, err = self.con:execute("SET CHARACTER SET utf8") - if ret == nil then - return nil, err - end - - return true -end - -function rddb:getCartInfo(cartnum) - local cur, err = self.con:execute("select TITLE,ARTIST,ALBUM from CART where NUMBER = " .. self.con:escape(cartnum)) - if cur == nil then - return nil, err - end - - if cur:numrows() ~= 1 then - return nil, "nothing found in rivendell db" - end - - local results = {} - results, err = cur:fetch(results, "a") - cur:close() - - if results.TITLE == nil then results.TITLE = "" end - if results.ARTIST == nil then results.ARTIST = "" end - if results.ALBUM == nil then results.ALBUM = "" end - - return results, err -end - -function rddb:close() - if self.con then - self.con:close() - end - - if self.env then - self.env:close() - end -end - -return rddb diff --git a/rhnop-server/tcpserver.lua b/rhnop-server/tcpserver.lua deleted file mode 100644 index fcc8a2e..0000000 --- a/rhnop-server/tcpserver.lua +++ /dev/null @@ -1,133 +0,0 @@ --- --- rhnop --- --- Copyright (C) 2011-2014 Christian Pointner --- --- This file is part of rhnop. --- --- rhnop is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- any later version. --- --- rhnop is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with rhnop. If not, see . --- - -require "socket" - -package.path = package.path .. ";" .. rhnoplibdir .. "/?.lua" -conf = require "conf" - -function init_server() - local server = assert(socket.tcp()) - - assert(server:setoption('reuseaddr', true)) - assert(server:bind(conf.tcp_host, conf.tcp_port)) - assert(server:listen(5)) - - return server -end - -local clients = {} - -function add_client(hdl) - -- print("new client(" .. hdl:getfd() .. ") from " .. hdl:getpeername()) - local client = {} - client.buffer = "" - client.hdl = hdl - client.getfd = function() return hdl:getfd() end - client.dirty = function() return hdl:dirty() end - table.insert(clients, client) -end - -function remove_client(c) - local idx = 0 - for idx, client in ipairs(clients) do - if client == c then - break - end - end - - -- print("removing client(" .. c.hdl:getfd() .. ")") - c.hdl:close() - table.remove(clients, idx) -end - -function cleanup_clients() - for _, client in ipairs(clients) do - client:close() - end -end - -function clients_get_writeables() - local fds = {} - - for _, client in ipairs(clients) do - if client.buffer ~= "" then - table.insert(fds, client) - end - end - - return fds -end - -function clients_senddata(timestamp) - for _, client in ipairs(clients) do - client.buffer = client.buffer .. timestamp .. "\n" - end -end - -function main_loop() - local pipefd = pipe.getreadfd() - - server = init_server() - while true do - local readables, writeables, err = socket.select({ pipefd , server , unpack(clients) } , clients_get_writeables()) - if err then - print("select returned with error: " .. err) - return -1 - else - for _, input in ipairs(readables) do - if input == pipefd then - local timestamp = pipe.consume() - if timestamp == nil then - return 2 - end - -- print("pipe was signaled with timestamp: " .. timestamp) - clients_senddata(timestamp) - elseif input == server then - local client = assert(server:accept()) - add_client(client) - else - if input.hdl then - -- receive is insanely stupid, therefore we must always read one byte only - local _, err = input.hdl:receive(1) - if err then - remove_client(input) - end - end - end - end - - for _, output in ipairs(writeables) do - local ret = output.hdl:send(output.buffer) - if(ret == nil) then - remove_client(output) - else - output.buffer = string.sub(output.buffer, ret+1) - end - end - end - end - - server:close() - cleanup_clients() - - return 0 -end -- cgit v0.10.2