diff options
Diffstat (limited to 'sys-power/apcupsd/files/apcupsd.init.4')
-rwxr-xr-x | sys-power/apcupsd/files/apcupsd.init.4 | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/sys-power/apcupsd/files/apcupsd.init.4 b/sys-power/apcupsd/files/apcupsd.init.4 index 3a0cd089..4caf4d27 100755 --- a/sys-power/apcupsd/files/apcupsd.init.4 +++ b/sys-power/apcupsd/files/apcupsd.init.4 @@ -8,14 +8,14 @@ if [ -z "${INSTANCE}" ] || [ "${SVCNAME}" = "apcupsd" ]; then INSTANCE="apcupsd" fi -dir="/var/run/apcupsd" +piddir="/var/run/apcupsd" depend() { use net } start_pre() { - checkpath -d -m 0775 -o root:uucp ${dir} + checkpath -d -m 0775 -o root:uucp ${piddir} } start() { @@ -23,27 +23,30 @@ start() { export SERVICE="${SVCNAME}" - if [ ! -d "${dir}" ]; then - einfo " Creating ${dir}" - /bin/mkdir -p "${dir}" - /bin/chown root:uucp "${dir}" - fi + local lockdir="$( grep -E '^\s*LOCKFILE\s+' "/etc/apcupsd/${INSTANCE}.conf" | sed -r 's/\s*LOCKFILE\s+//' )" + local dir + for dir in "${piddir}" "${lockdir}"; do + if [ ! -d "${dir}" ]; then + einfo " Creating ${dir}" + /bin/mkdir -p "${dir}" + fi + done + /bin/chown root:uucp "${piddir}" ebegin "Starting APC UPS daemon" start-stop-daemon \ - --start --pidfile "${dir}/${SVCNAME}.pid" \ + --start --pidfile "${piddir}/${SVCNAME}.pid" \ --exec /sbin/apcupsd -- \ -f "/etc/apcupsd/${INSTANCE}.conf" \ - -P "${dir}/${SVCNAME}.pid" + -P "${piddir}/${SVCNAME}.pid" eend $? } stop() { ebegin "Stopping APC UPS daemon" start-stop-daemon \ - --stop --pidfile "${dir}/${SVCNAME}.pid" \ + --stop --pidfile "${piddir}/${SVCNAME}.pid" \ --retry TERM/5/TERM/5 \ --exec /sbin/apcupsd eend $? } - |