Skip to content

Commit

Permalink
Added oneshot service at init to check for and remove any potential l…
Browse files Browse the repository at this point in the history
…eftover cwa lock files (cwa-init-remove-locks)
  • Loading branch information
crocodilestick committed Sep 18, 2024
1 parent 701b584 commit afbb32a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
Empty file.
25 changes: 25 additions & 0 deletions root/etc/s6-overlay/s6-rc.d/cwa-init-remove-locks/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

declare -a lockFiles=("new-book-processor.lock")

echo "[cwa-init-remove-locks] Checking for leftover lock files from prvious instance..."

counter=0

for f in "${lockFiles[@]}"
do
if [ -f "/tmp/$f" ]
then
echo "[cwa-init-remove-locks] Leftover $f exists, removing now..."
rm "/tmp/$f"
echo "[cwa-init-remove-locks] Leftover $f removed."
let counter++
fi
done

if [[ "$counter" -eq 0 ]]
then
echo "[cwa-init-remove-locks] No leftover lock files to remove. Ending service..."
else
echo "[cwa-init-remove-locks] $counter lock file(s) removed. Ending service..."
fi
1 change: 1 addition & 0 deletions root/etc/s6-overlay/s6-rc.d/cwa-init-remove-locks/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions root/etc/s6-overlay/s6-rc.d/cwa-init-remove-locks/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/cwa-init-remove-locks/run
Empty file.

0 comments on commit afbb32a

Please sign in to comment.