Skip to content

Commit

Permalink
startup.sh: fix locking
Browse files Browse the repository at this point in the history
  • Loading branch information
Informatic committed Feb 22, 2022
1 parent 5beacc6 commit 4d3667e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions services/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@
# Ensure that startup script runs only once per boot
once=/tmp/webosbrew_startup
exec 200>"${once}.lock"
flock -x -n 200 || (echo "[!] Startup script already running" >&2 ; exit 1)

if ! flock -x -n 200; then
echo "[!] Startup script already running" >&2
exit 1
fi

trap "rm -f ${once}.lock" EXIT
test -f "${once}" && (echo "[!] Startup script finished already" >&2; exit 2)

if test -f "${once}"; then
echo "[!] Startup script finished already" >&2
exit 2
fi

touch "${once}"

if [[ -f /var/luna/preferences/webosbrew_failsafe ]]; then
Expand Down

0 comments on commit 4d3667e

Please sign in to comment.