Feat: Passt die lock-Funktionen an, dass sie einen Parameter entgegen nimmt.
This commit is contained in:
parent
338bec55e9
commit
65fc9d0c69
@ -5,21 +5,37 @@ if [[ ! -w "$LOCK_DIR" ]]; then
|
||||
LOCK_DIR="/tmp" # Fallback für benutzerspezifische Locks
|
||||
fi
|
||||
|
||||
LOCK_FILE="$LOCK_DIR/$(basename "$0").lock"
|
||||
# Funktion zur Erstellung des Lock-Dateinamens
|
||||
get_lock_file() {
|
||||
local suffix="$1"
|
||||
if [[ -n "$suffix" ]]; then
|
||||
echo "$LOCK_DIR/$(basename "$0")_$suffix.lock"
|
||||
else
|
||||
echo "$LOCK_DIR/$(basename "$0").lock"
|
||||
fi
|
||||
}
|
||||
|
||||
create_lock() {
|
||||
if [[ -e "$LOCK_FILE" ]]; then
|
||||
log "Ein anderer Prozess läuft bereits. Lock-File gefunden: $LOCK_FILE"
|
||||
local suffix="$1"
|
||||
local lock_file
|
||||
lock_file=$(get_lock_file "$suffix")
|
||||
|
||||
if [[ -e "$lock_file" ]]; then
|
||||
log "Ein anderer Prozess läuft bereits. Lock-File gefunden: $lock_file"
|
||||
exit 1
|
||||
fi
|
||||
touch "$LOCK_FILE"
|
||||
log "Lock-File erstellt: $LOCK_FILE"
|
||||
touch "$lock_file"
|
||||
log "Lock-File erstellt: $lock_file"
|
||||
}
|
||||
|
||||
remove_lock() {
|
||||
if [[ -e "$LOCK_FILE" ]]; then
|
||||
rm -f "$LOCK_FILE"
|
||||
log "Lock-File entfernt: $LOCK_FILE"
|
||||
local suffix="$1"
|
||||
local lock_file
|
||||
lock_file=$(get_lock_file "$suffix")
|
||||
|
||||
if [[ -e "$lock_file" ]]; then
|
||||
rm -f "$lock_file"
|
||||
log "Lock-File entfernt: $lock_file"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user