Fixed prog_lock so multiple different plugins could run

This commit is contained in:
Eric Renfro 2017-08-20 00:51:52 -04:00
parent e013ec9198
commit 744be856b0

View file

@ -373,12 +373,14 @@ check-update() {
} }
prog_lock() { prog_lock() {
local lock_name=$1
## Locking ## Locking
if [[ "$USER" = "root" ]]; then if [[ "$USER" == "root" ]]; then
LOCKFILE="/var/lock/$(basename "$0")" LOCKFILE="/var/lock/${lock_name}"
else else
LOCKFILE="/tmp/${USER}/lock/$(basename "$0")" LOCKFILE="/tmp/${USER}/lock/${lock_name}"
mkdir -p "/tmp/${USER}/lock" mkdir -p "/tmp/${USER}/lock"
fi fi
LOCKFD=99 LOCKFD=99
@ -412,14 +414,13 @@ prog_lock() {
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
# Internal Initialization # Internal Initialization
#prog_name=$(basename "$0") prog_name=$(basename "$0")
script_dir=$(dirname "$(readlink -f "$0")") script_dir=$(dirname "$(readlink -f "$0")")
prog_lock
# Main # Main
if [[ -r "${script_dir}/plugins/${1}" ]]; then if [[ -r "${script_dir}/plugins/${1}" ]]; then
prog_lock "${prog_name}-${1}"
# shellcheck source=plugins/update-ipv4 # shellcheck source=plugins/update-ipv4
source "${script_dir}/plugins/${1}" source "${script_dir}/plugins/${1}"
else else