From b3e6f5f7e0cf75ff1c4320b2e1485951647a4f4d Mon Sep 17 00:00:00 2001 From: Antoine Jacoutot Date: Wed, 28 May 2014 10:44:35 +0200 Subject: [PATCH] Make sure we are not running several instances. idea from otto@openbsd --- openup | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/openup b/openup index b1ff00e..d2dcad9 100755 --- a/openup +++ b/openup @@ -95,10 +95,11 @@ _TMPDIR=$(mktemp -dp ${_TMP} .openup-XXXXXXXXXX) || exit 1 _TMPKEY="${_TMPDIR}/key" _TMPSPLITCERT="${_TMPDIR}/cert" _TMPVUXML="${_TMPDIR}/vuxml" +_PID="/var/run/${0##*/}.pid" export PKG_PATH=${PKG_PATH_UPDATE}:${PKG_PATH_MAIN} -trap "rm -rf ${_TMPDIR}" 1 2 3 13 15 +trap "rm -rf ${_TMPDIR} ${_PID}" 1 2 3 13 15 pr_bigarrow() { if [ -z "${checkmode}" ]; then @@ -303,6 +304,13 @@ if [ "${checkmode}" ]; then fi fi +if [ -f ${_PID} ]; then + pr_error "openup is already running ($(cat ${_PID})):" + pr_error "${_PID}" + exit 1 +fi +echo $$ >${_PID} + check_openupd if [ -n "${exclude_kernel}" ]; then @@ -330,3 +338,4 @@ fi do_i_need_to_reboot rm -rf ${_TMPDIR} +rm ${_PID}