-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Safeguard suibase-daemon from being started without file lock.
- Loading branch information
1 parent
007547c
commit 3633722
Showing
5 changed files
with
107 additions
and
20 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
# Source '__globals.sh'. | ||
SUIBASE_DIR="$HOME/suibase" | ||
SCRIPT_COMMON_CALLER="$(readlink -f "$0")" | ||
WORKDIR="none" | ||
|
||
# Validate that the parameter is a number | ||
if [ -z "$1" ]; then | ||
echo "ERROR: Missing PID to check" | ||
exit 1 | ||
fi | ||
|
||
if ! [[ "$1" =~ ^[0-9]+$ ]]; then | ||
echo "ERROR: Invalid PID: $1" | ||
exit 1 | ||
fi | ||
|
||
# shellcheck source=SCRIPTDIR/__globals.sh | ||
source "$SUIBASE_DIR/scripts/common/__globals.sh" "$SCRIPT_COMMON_CALLER" "$WORKDIR" | ||
trap cleanup EXIT | ||
|
||
# shellcheck source=SCRIPTDIR/__suibase-daemon.sh | ||
source "$SUIBASE_DIR/scripts/common/__suibase-daemon.sh" | ||
|
||
# Get the PID of suibase (under the lock file) | ||
update_SUIBASE_DAEMON_PID_var | ||
|
||
if [ -z "$SUIBASE_DAEMON_PID" ]; then | ||
echo "ERROR: suibase daemon not running under lock" | ||
exit 1 | ||
fi | ||
|
||
if [ "$1" != "$SUIBASE_DAEMON_PID" ]; then | ||
echo "ERROR: PID $1 is not the suibase-daemon PID under proper lock ($SUIBASE_DAEMON_PID)" | ||
exit 1 | ||
fi | ||
|
||
echo "OK" | ||
exit 0 |