aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2020-02-14 17:20:43 +0200
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2020-02-14 17:20:43 +0200
commit861b1e6f895794e78b5f830b0816d6d547a828cd (patch)
tree4ec56784f4b5de18548a79e21f8bcb8dc0d9e310
parente73992f1225d5548ad29e492fdd58a6ed137f656 (diff)
downloadaports-861b1e6f895794e78b5f830b0816d6d547a828cd.tar.bz2
aports-861b1e6f895794e78b5f830b0816d6d547a828cd.tar.xz
testing/in-sync: new package
-rw-r--r--testing/in-sync/APKBUILD27
-rw-r--r--testing/in-sync/in-sync29
-rw-r--r--testing/in-sync/in-sync.conf1
-rw-r--r--testing/in-sync/in-sync.initd14
4 files changed, 71 insertions, 0 deletions
diff --git a/testing/in-sync/APKBUILD b/testing/in-sync/APKBUILD
new file mode 100644
index 0000000000..e966670839
--- /dev/null
+++ b/testing/in-sync/APKBUILD
@@ -0,0 +1,27 @@
+# Contributor: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
+# Maintainer:
+pkgname=in-sync
+pkgver=0.1.0
+pkgrel=0
+pkgdesc="inotify-triggered file synchronization"
+url=https://git.alpinelinux.org/cgit/aports/tree/testing/in-sync
+arch=noarch
+license=GPL2
+depends="inotify-tools rsync"
+subpackages=$pkgname-openrc
+source="in-sync in-sync.conf in-sync.initd"
+options="!check"
+
+build() {
+ :
+}
+
+package() {
+ install -D -m 755 "$srcdir/in-sync" "$pkgdir/usr/sbin/in-sync"
+ install -D -m 644 "$srcdir/in-sync.conf" "$pkgdir/etc/in-sync.conf"
+ install -D -m 755 "$srcdir/in-sync.initd" "$pkgdir/etc/init.d/in-sync"
+}
+
+sha512sums="e525963135dbf185385fc1739b9241efd149ca14b9198eb52c3667f5ba13bbc924b7192d937179dde8eab2edff0e7d108b72ef75ef5adb0320202cf3838f1c7d in-sync
+27f1f36437f245e3555d598228ddc81c9ddc217fc54aadaa4135cb3b2794559b485c220e3d481efb600f5386f41af8566c409b6353e9d3f563dfce08a9e9bf78 in-sync.conf
+de73c5375f734a0e1955ee7d2e3f2474e23ff0f8ddcd310a5eb774d208e4de13005d640a3c8fb22ac63b88040a6f7cc88b5723b8ac28829a3784aac2e04a7bd2 in-sync.initd"
diff --git a/testing/in-sync/in-sync b/testing/in-sync/in-sync
new file mode 100644
index 0000000000..421974dc9e
--- /dev/null
+++ b/testing/in-sync/in-sync
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+# inotify-triggered file synchronization
+# Copyright (c) 2020 Kaarle Ritvanen
+
+. /etc/in-sync.conf
+
+log() {
+ logger -p daemon.$1 "$(basename "$0"): $2"
+}
+
+list_files() {
+ local path
+ cat /etc/in-sync.d/* | while read path; do
+ [ -e "$path" ] && echo "$path"
+ done
+}
+
+while :; do
+ for host in $TARGET_HOSTS; do
+ if list_files | rsync -avz --files-from - / $host:/; then
+ log info "successfully synchronized to $host"
+ else
+ log err "synchronization to $host failed"
+ fi
+ done
+ list_files | inotifywait -e close_write -t 900 --fromfile -
+ [ $? -eq 1 ] && sleep 60
+done
diff --git a/testing/in-sync/in-sync.conf b/testing/in-sync/in-sync.conf
new file mode 100644
index 0000000000..4931f8ccbc
--- /dev/null
+++ b/testing/in-sync/in-sync.conf
@@ -0,0 +1 @@
+TARGET_HOSTS=""
diff --git a/testing/in-sync/in-sync.initd b/testing/in-sync/in-sync.initd
new file mode 100644
index 0000000000..9cc86c0109
--- /dev/null
+++ b/testing/in-sync/in-sync.initd
@@ -0,0 +1,14 @@
+#!/sbin/openrc-run
+
+# inotify-triggered file synchronization
+# Copyright (c) 2020 Kaarle Ritvanen
+
+name=in-sync
+command=/usr/sbin/in-sync
+command_background=1
+pidfile=/var/run/$name.pid
+
+depend() {
+ need net
+ after firewall
+}