summaryrefslogtreecommitdiff
path: root/manualPorts/bareos-filedaemon/check-if-bareos-backup-is-running
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2020-04-26 22:18:27 +0200
committerErich Eckner <git@eckner.net>2020-04-26 22:18:27 +0200
commit9cc46019e72abe6c110265fe3b5f5a7d80439086 (patch)
tree4e51777d5fdb5541a1d399316391f8dcafa3855c /manualPorts/bareos-filedaemon/check-if-bareos-backup-is-running
parent2cf56c46db7c1972b74f758cfd5a9c1ea08f56f9 (diff)
downloadcrux-ports-9cc46019e72abe6c110265fe3b5f5a7d80439086.tar.xz
bareos-filedaemon: check-if-bareos-backup-is-running fixed
Diffstat (limited to 'manualPorts/bareos-filedaemon/check-if-bareos-backup-is-running')
-rwxr-xr-xmanualPorts/bareos-filedaemon/check-if-bareos-backup-is-running53
1 files changed, 11 insertions, 42 deletions
diff --git a/manualPorts/bareos-filedaemon/check-if-bareos-backup-is-running b/manualPorts/bareos-filedaemon/check-if-bareos-backup-is-running
index e638869..bc3d2e1 100755
--- a/manualPorts/bareos-filedaemon/check-if-bareos-backup-is-running
+++ b/manualPorts/bareos-filedaemon/check-if-bareos-backup-is-running
@@ -5,46 +5,15 @@ if [ $# -ne 0 ]; then
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
+if cat /proc/net/tcp* \
+| awk '{print $2 " " $3}' \
+| grep -vw '\(000000000000000000000000\)\?00000000:0000' \
+| tr ' ' '\n' \
+| grep -F : \
+| cut -d: -f2 \
+| grep -qxiF '238F'; then
+ >&2 echo 'bareos-fd is connected to bareos-sd'
+ exit 1
+else
+ >&2 echo 'bareos-fd is not connected to bareos-sd'
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
- >&2 echo 'bareos-fd is reading'
- exit 1
- fi
-done
->&2 echo 'bareos-fd is not reading'