From f341472c1716c2d1fb692e187785c7972bfc90c6 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 31 Jan 2022 01:46:35 +0100 Subject: [PATCH] Ensure that only one autorotate instance runs at the time --- bin/autorotate | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/autorotate b/bin/autorotate index 8f8f6e2..37659bb 100755 --- a/bin/autorotate +++ b/bin/autorotate @@ -1,5 +1,12 @@ #!/bin/bash +pidfile=/tmp/autorotate.pid +if ps -p $(cat "$pidfile" 2>/dev/null) >/dev/null; then + echo "An autorotate process is already running - if not please remove $pidfile" >&2 + exit 1 +fi + +echo $$ > "$pidfile" script_dir="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" source "$script_dir/cutiepi-screen-common"