summaryrefslogtreecommitdiff
path: root/bareos
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-05-03 11:39:38 +0200
committerErich Eckner <git@eckner.net>2019-05-03 11:39:38 +0200
commit3104d1a4e932d37dc8f0565822a8c24414c32d3d (patch)
tree8b2071595cd93f26ac89b00c77a47d1431f54ea5 /bareos
parent8f6246c0f3eaa0d281ea32cb1f2ad5075e0ebf71 (diff)
downloadarchlinuxewe-3104d1a4e932d37dc8f0565822a8c24414c32d3d.tar.xz
bareos: /usr/bin/check-if-bareos-backup-is-running new
Diffstat (limited to 'bareos')
-rw-r--r--bareos/PKGBUILD10
-rwxr-xr-xbareos/check-if-bareos-backup-is-running48
2 files changed, 55 insertions, 3 deletions
diff --git a/bareos/PKGBUILD b/bareos/PKGBUILD
index 44c294545..773213ee4 100644
--- a/bareos/PKGBUILD
+++ b/bareos/PKGBUILD
@@ -22,7 +22,7 @@ pkgname=("${pkgbase}-common"
"${pkgbase}-storage-python-plugin")
pkgver=18.2.6
-pkgrel=4
+pkgrel=5
arch=(x86_64 i686 pentium4 armv7h aarch64)
groups=('bareos')
pkgdesc="Bareos - Backup Archiving REcovery Open Sourced"
@@ -33,9 +33,11 @@ makedepends_x86_64=(ceph)
makedepends_armv7h=(ceph)
makedepends_aarch64=(ceph)
source=("$pkgbase-$pkgver.tar.gz::https://github.com/$pkgbase/$pkgbase/archive/Release/$pkgver.tar.gz"
-'nullify-os-specifics.patch')
+'nullify-os-specifics.patch'
+'check-if-bareos-backup-is-running')
sha512sums=('b6618173a803db4cfc3fe7edfe8c9e4e4128195f44383cd7df5b9866da4290686ed7cb42499edec957a5d9ab8bbd92d26258ce58f13fba84fb569167956768c3'
- '0d6683bb21e06e005b4d5f7dd31d24adac0001ab202ccd806d31af1fda48a1a78156a18e8cc8847b80a7de01c0b58fa6ab7a1ba7f8f056d0de414c472db11643')
+ '0d6683bb21e06e005b4d5f7dd31d24adac0001ab202ccd806d31af1fda48a1a78156a18e8cc8847b80a7de01c0b58fa6ab7a1ba7f8f056d0de414c472db11643'
+ '9d5a37de458d0e5adb8a29adb46c132dbce9d42d6736e7eee9eac0e7f5c153627859e1b84a2074882a58381af2ffc9c9e9629c1dd884acfd2888e2f8ce00c119')
prepare() {
cd "${srcdir}/${pkgbase}-Release-${pkgver}"
@@ -373,6 +375,8 @@ package_bareos-filedaemon() {
_cp $srcdir/install/$f $pkgdir/$f
done
+ install -Dm 755 -t "$pkgdir/usr/bin/" "$srcdir/check-if-bareos-backup-is-running"
+
# Currently upstream systemd file does not automatically create run directory
sed -i '/\[Service\]/a RuntimeDirectory=bareos' $srcdir/bareos-Release-$pkgver/core/platforms/systemd/bareos-fd.service
_cp $srcdir/bareos-Release-$pkgver/core/platforms/systemd/bareos-fd.service $pkgdir/usr/lib/systemd/system/bareos-fd.service
diff --git a/bareos/check-if-bareos-backup-is-running b/bareos/check-if-bareos-backup-is-running
new file mode 100755
index 000000000..b9a71307d
--- /dev/null
+++ b/bareos/check-if-bareos-backup-is-running
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+if [ $# -ne 0 ]; then
+ >&2 echo 'check-if-bareos-backup-is-running: too many arguments'
+ exit 2
+fi
+
+bareos_pid=$(
+ pgrep -xf '(.*/)?bareos-fd' \
+ | head -n1
+)
+
+if [ -z "${bareos_pid}" ]; then
+ >&2 echo 'check-if-bareos-backup-is-running: cannot find running bareos-fd'
+ exit 2
+fi
+
+if ! grep -qxF bareos-fd "/proc/${bareos_pid}/comm"; then
+ >&2 echo 'check-if-bareos-backup-is-running: cannot find running bareos-fd'
+ exit 2
+fi
+
+if [ $(whoami) != 'root' ]; then
+ >&2 echo 'check-if-bareos-backup-is-running: must be run as root'
+ exit 2
+fi
+
+time_out=$((
+ $(date +%s)+30
+))
+was=$(
+ sed '
+ s/^read_bytes: //
+ t
+ d
+ ' "/proc/${bareos_pid}/io"
+)
+while [ $(date +%s) -le ${time_out} ]; do
+ sleep 1
+ if sed '
+ s/^read_bytes: //
+ t
+ d
+ ' "/proc/${bareos_pid}/io" \
+ | grep -qvxF "${was}"; then
+ exit 1
+ fi
+done