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