arch-pkgs/rtorrent-systemd/cleanlock
George Rawlinson 40a7250c58
build: import forked packages
Packages from either the AUR or generated by myself.
2021-07-24 10:00:59 +00:00

16 lines
437 B
Bash

#!/bin/bash
SESSIONDIR="/var/lib/rtorrent/session"
LOCKFILE="$SESSIONDIR/rtorrent.lock"
if [[ -f "$LOCKFILE" ]]; then
# extract PID from lockfile
PIDRT="$(awk -F: '{print($2)}' "${LOCKFILE}" | sed "s/[^0-9]//g")"
# delete lockfile if PIDRT empty or if rtorrent is not said PID
if [[ -z "$PIDRT" ]] || [[ "$(pgrep rtorrent)" -ne "$PIDRT" ]]; then
rm -f "$LOCKFILE"
fi
fi
exit 0