From 87bfb0cc66d08751dd3c3104006b27ebe9fb5646 Mon Sep 17 00:00:00 2001
From: Christian Pointner <equinox@helsinki.at>
Date: Fri, 15 May 2015 01:27:28 +0200
Subject: renamed nopcollectd to nopsyncd


diff --git a/debian/rhnop-client.install b/debian/rhnop-client.install
index 6b9cf7e..bd78579 100644
--- a/debian/rhnop-client.install
+++ b/debian/rhnop-client.install
@@ -1,5 +1,5 @@
-usr/bin/nopcollectd
+usr/bin/nopsyncd
 usr/bin/nopsysstated
-etc/rhnop/nopcollectd.*.conf
+etc/rhnop/nopsyncd.*.conf
 etc/rhnop/nopsysstated.conf
 usr/share/rhnop/db.lua
diff --git a/debian/rhnop-client.nopcollectd-master.service b/debian/rhnop-client.nopcollectd-master.service
deleted file mode 100644
index 12b8905..0000000
--- a/debian/rhnop-client.nopcollectd-master.service
+++ /dev/null
@@ -1,13 +0,0 @@
-[Unit]
-Description=Radio Helsinki Now Playing Daemon (Client: Master)
-
-[Service]
-ExecStart=/usr/bin/nopcollectd master
-Restart=on-failure
-PrivateTmp=yes
-PrivateDevices=yes
-ProtectSystem=full
-ProtectHome=yes
-
-[Install]
-WantedBy=multi-user.target
diff --git a/debian/rhnop-client.nopcollectd-standby.service b/debian/rhnop-client.nopcollectd-standby.service
deleted file mode 100644
index 251f09b..0000000
--- a/debian/rhnop-client.nopcollectd-standby.service
+++ /dev/null
@@ -1,13 +0,0 @@
-[Unit]
-Description=Radio Helsinki Now Playing Daemon (Client: Standby)
-
-[Service]
-ExecStart=/usr/bin/nopcollectd standby
-Restart=on-failure
-PrivateTmp=yes
-PrivateDevices=yes
-ProtectSystem=full
-ProtectHome=yes
-
-[Install]
-WantedBy=multi-user.target
diff --git a/debian/rhnop-client.nopsyncd-master.service b/debian/rhnop-client.nopsyncd-master.service
new file mode 100644
index 0000000..051d817
--- /dev/null
+++ b/debian/rhnop-client.nopsyncd-master.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Radio Helsinki Now Playing Daemon (Client: Master)
+
+[Service]
+ExecStart=/usr/bin/nopsyncd master
+Restart=on-failure
+PrivateTmp=yes
+PrivateDevices=yes
+ProtectSystem=full
+ProtectHome=yes
+
+[Install]
+WantedBy=multi-user.target
diff --git a/debian/rhnop-client.nopsyncd-standby.service b/debian/rhnop-client.nopsyncd-standby.service
new file mode 100644
index 0000000..64518c2
--- /dev/null
+++ b/debian/rhnop-client.nopsyncd-standby.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Radio Helsinki Now Playing Daemon (Client: Standby)
+
+[Service]
+ExecStart=/usr/bin/nopsyncd standby
+Restart=on-failure
+PrivateTmp=yes
+PrivateDevices=yes
+ProtectSystem=full
+ProtectHome=yes
+
+[Install]
+WantedBy=multi-user.target
diff --git a/debian/rules b/debian/rules
index d82394a..35cc3c8 100755
--- a/debian/rules
+++ b/debian/rules
@@ -8,5 +8,5 @@ override_dh_auto_configure:
 override_dh_systemd_enable:
 	dh_systemd_enable --name=nopfetchd nopfetchd.service
 	dh_systemd_enable --name=nopsysstated nopsysstated.service
-	dh_systemd_enable --name=nopcollectd-master nopcollectd-master.service
-	dh_systemd_enable --name=nopcollectd-standby nopcollectd-standby.service
+	dh_systemd_enable --name=nopsyncd-master nopsyncd-master.service
+	dh_systemd_enable --name=nopsyncd-standby nopsyncd-standby.service
diff --git a/src/Makefile b/src/Makefile
index b478018..f71d8a0 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -75,9 +75,9 @@ install-bin: $(EXECUTABLE)
 	$(INSTALL) -d $(DESTDIR)$(BINDIR)
 	$(INSTALL) -m 755 $(EXECUTABLE) $(DESTDIR)$(BINDIR)
 	$(INSTALL) -m 755 noprml $(DESTDIR)$(BINDIR)
-	$(INSTALL) -m 755 nopcollectd $(DESTDIR)$(BINDIR)
-	$(SED) -e 's#_rhnopescdir_#$(ETCDIR)/rhnop#' -i $(DESTDIR)$(BINDIR)/nopcollectd
-	$(SED) -e 's#_rhnoplibdir_/?.lua#$(DATAROOTDIR)/rhnop/?.lua#' -i $(DESTDIR)$(BINDIR)/nopcollectd
+	$(INSTALL) -m 755 nopsyncd $(DESTDIR)$(BINDIR)
+	$(SED) -e 's#_rhnopescdir_#$(ETCDIR)/rhnop#' -i $(DESTDIR)$(BINDIR)/nopsyncd
+	$(SED) -e 's#_rhnoplibdir_/?.lua#$(DATAROOTDIR)/rhnop/?.lua#' -i $(DESTDIR)$(BINDIR)/nopsyncd
 	$(INSTALL) -m 755 nopsysstated $(DESTDIR)$(BINDIR)
 	$(SED) -e 's#_rhnopescdir_#$(ETCDIR)/rhnop#' -i $(DESTDIR)$(BINDIR)/nopsysstated
 	$(SED) -e 's#_rhnoplibdir_/?.lua#$(DATAROOTDIR)/rhnop/?.lua#' -i $(DESTDIR)$(BINDIR)/nopsysstated
@@ -94,7 +94,7 @@ install-lib:
 install-etc:
 	$(INSTALL) -d $(DESTDIR)$(ETCDIR)/rhnop
 	$(INSTALL) -m 640 nopfetchd.conf $(DESTDIR)$(ETCDIR)/rhnop
-	$(INSTALL) -m 640 nopcollectd.*.conf $(DESTDIR)$(ETCDIR)/rhnop
+	$(INSTALL) -m 640 nopsyncd.*.conf $(DESTDIR)$(ETCDIR)/rhnop
 	$(INSTALL) -m 640 nopsysstated.conf $(DESTDIR)$(ETCDIR)/rhnop
 
 uninstall: remove
@@ -104,7 +104,7 @@ remove: $(REMOVE_TARGETS)
 remove-bin:
 	rm -f $(DESTDIR)$(BINDIR)/$(EXECUTABLE)
 	rm -f $(DESTDIR)$(BINDIR)/noprml
-	rm -f $(DESTDIR)$(BINDIR)/nopcollectd
+	rm -f $(DESTDIR)$(BINDIR)/nopsyncd
 	rm -f $(DESTDIR)$(BINDIR)/nopsysstated
 
 remove-lib:
diff --git a/src/db.lua b/src/db.lua
index d244bad..e10e762 100644
--- a/src/db.lua
+++ b/src/db.lua
@@ -23,8 +23,8 @@ 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 '<password>';
--- GRANT select,insert,update,delete ON nop.standby TO 'nopcollectd'@'localhost';
+-- GRANT select,insert,update,delete ON nop.master TO 'nopsyncd'@'localhost' IDENTIFIED BY '<password>';
+-- GRANT select,insert,update,delete ON nop.standby TO 'nopsyncd'@'localhost';
 -- GRANT select,insert,update ON nop.state TO 'nopsysstated'@'localhost' IDENTIFIED BY '<password>';
 -- GRANT select ON nop.* TO 'nop'@'localhost' IDENTIFIED BY '<password>';
 -- USE nop
diff --git a/src/nopcollectd b/src/nopcollectd
deleted file mode 100755
index d02e6f0..0000000
--- a/src/nopcollectd
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/lua
---
---  rhnop
---
---  Copyright (C) 2011-2015 Christian Pointner <equinox@helsinki.at>
---
---  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 <http://www.gnu.org/licenses/>.
---
-
-socket = require "socket"
-
-package.path = package.path .. ";_rhnoplibdir_/?.lua"
-db = require "db"
-conf = require "conf"
-
-if #arg < 1 then
-   io.stderr:write("too few parameters\n")
-   os.exit(1)
-end
-
-local cnf = conf.load("_rhnopescdir_/nopcollectd." .. arg[1] .. ".conf")
-
-src_db = assert(db.init(cnf.src_db, cnf.src_user, cnf.src_pwd, cnf.src_host, cnf.src_port, cnf.src_table))
-dst_db = assert(db.init(cnf.dst_db, cnf.dst_user, cnf.dst_pwd, cnf.dst_host, cnf.dst_port, cnf.dst_table))
-
-local sock = assert(socket.tcp())
-local ret, err = sock:connect(cnf.sync_host, cnf.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/src/nopcollectd.master.conf b/src/nopcollectd.master.conf
deleted file mode 100644
index 5d61551..0000000
--- a/src/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/src/nopcollectd.standby.conf b/src/nopcollectd.standby.conf
deleted file mode 100644
index 92ba1aa..0000000
--- a/src/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/src/nopsyncd b/src/nopsyncd
new file mode 100755
index 0000000..f67f2c4
--- /dev/null
+++ b/src/nopsyncd
@@ -0,0 +1,70 @@
+#!/usr/bin/lua
+--
+--  rhnop
+--
+--  Copyright (C) 2011-2015 Christian Pointner <equinox@helsinki.at>
+--
+--  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 <http://www.gnu.org/licenses/>.
+--
+
+socket = require "socket"
+
+package.path = package.path .. ";_rhnoplibdir_/?.lua"
+db = require "db"
+conf = require "conf"
+
+if #arg < 1 then
+   io.stderr:write("too few parameters\n")
+   os.exit(1)
+end
+
+local cnf = conf.load("_rhnopescdir_/nopsyncd." .. arg[1] .. ".conf")
+
+src_db = assert(db.init(cnf.src_db, cnf.src_user, cnf.src_pwd, cnf.src_host, cnf.src_port, cnf.src_table))
+dst_db = assert(db.init(cnf.dst_db, cnf.dst_user, cnf.dst_pwd, cnf.dst_host, cnf.dst_port, cnf.dst_table))
+
+local sock = assert(socket.tcp())
+local ret, err = sock:connect(cnf.sync_host, cnf.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/src/nopsyncd.master.conf b/src/nopsyncd.master.conf
new file mode 100644
index 0000000..35e6ebc
--- /dev/null
+++ b/src/nopsyncd.master.conf
@@ -0,0 +1,16 @@
+sync_host=airplay.helsinki.at
+sync_port=2345
+
+src_db=rhnop
+src_table=now
+src_host=airplay.helsinki.at
+#src_port=3306
+src_user=nopsyncd
+src_pwd=123456
+
+dst_db=nop
+dst_table=master
+dst_host=127.0.0.1
+#dst_port=3306
+dst_user=nopsyncd
+dst_pwd=123456
diff --git a/src/nopsyncd.standby.conf b/src/nopsyncd.standby.conf
new file mode 100644
index 0000000..62da2a3
--- /dev/null
+++ b/src/nopsyncd.standby.conf
@@ -0,0 +1,16 @@
+sync_host=airplay2.helsinki.at
+sync_port=2345
+
+src_db=rhnop
+src_table=now
+src_host=airplay2.helsinki.at
+#src_port=3306
+src_user=nopsyncd
+src_pwd=123456
+
+dst_db=nop
+dst_table=standby
+dst_host=127.0.0.1
+#dst_port=3306
+dst_user=nopsyncd
+dst_pwd=123456
diff --git a/src/playlog.lua b/src/playlog.lua
index 1dea4e9..5f97850 100644
--- a/src/playlog.lua
+++ b/src/playlog.lua
@@ -23,7 +23,7 @@ luasql = require "luasql.mysql"
 
 -- CREATE DATABASE rhnop CHARACTER SET utf8 COLLATE utf8_unicode_ci;
 -- GRANT select,insert,update ON rhnop.* TO 'nopfetchd' IDENTIFIED BY '<password>';
--- GRANT select ON rhnop.* TO 'nopcollectd' IDENTIFIED BY '<password>';
+-- GRANT select ON rhnop.* TO 'nopsyncd' IDENTIFIED BY '<password>';
 -- 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;
-- 
cgit v0.10.2