[crux-commits] ports/contrib (3.6): acpid: import rc file, only comment backgrounding in default handler

crux at crux.nu crux at crux.nu
Thu Mar 18 19:24:05 UTC 2021


commit 4b64b0cec6d07d791b09efda18803fa601321b47
Author: Steffen Nurpmeso <steffen at sdaoden.eu>
Date:   Thu Mar 18 18:24:59 2021 +0100

    acpid: import rc file, only comment backgrounding in default handler

diff --git a/acpid/.signature b/acpid/.signature
index d7c410ae5..bc4be1f6a 100644
--- a/acpid/.signature
+++ b/acpid/.signature
@@ -1,8 +1,8 @@
 untrusted comment: verify with /etc/ports/contrib.pub
-RWSagIOpLGJF3+6R/hnpC8JBl5rZ1W8BRneobnugk6vdHrPlbBg5zmBeCco8LIRUKvKelUOrsicwKDYjU7/4p4vUCjRs+kjisAY=
+RWSagIOpLGJF3zQFtB6F25a8Yhnk0f7uwe2NxlDvqlscp5tlFGScdYrTym3SsxizLs2PzhKBNTngNWzWXTcl+SDfYsiwCzoeTQc=
 SHA256 (Pkgfile) = e479d9528d93c8b6ca683d742da204b79209f22c52dda058dc4b740c0a3be89e
 SHA256 (.footprint) = e4da2ef20c91becc9458692dcb62589feb4e6da8e4a5724133d1e5d0456fa602
 SHA256 (acpid-2.0.32.tar.xz) = f2d2d30b3edc3234bd82f6f7186699a6aa3c85c8d20bc4e30e9b3c68a1ed157e
-SHA256 (acpid.rc) = 17ad7f6f021a01f9d45578a776988f557511761467b2494dcba181ed48dd703b
+SHA256 (acpid.rc) = 70ec38cfc4c48b700218cd946f44c6c10ed541a2e84154284431c429144c74a8
 SHA256 (default) = 1263501c5d3abe1c0d4ce43b584d7129a6d454d312f3485d3a7b64d2839605b0
-SHA256 (default.sh) = 97be75867cad9c0e976474f1303547225b0036e94d1fdea11e8297adc6e02f6c
+SHA256 (default.sh) = 5e599d98dbad015b538e476e20c6e60289d4ba9759517ee653cba2dd778fc29c
diff --git a/acpid/acpid.rc b/acpid/acpid.rc
index 5ed5e9d24..45770b071 100644
--- a/acpid/acpid.rc
+++ b/acpid/acpid.rc
@@ -1,50 +1,46 @@
 #!/bin/sh
-######################################################################
-# acpid: starts/stops ACPI daemon
-######################################################################
+#@ acpid2 startup script.
 
-daemon="/usr/sbin/acpid"
-options="-c /etc/acpi/events"
+RD=/var/run
+CONFDIR=/etc/acpi/events
+PID=${RD}/acpid.pid
+LCK=${RD}/acpid.lck
+SCK=${RD}/acpid.socket
 
-######################################################################
-# Start/Stop/Reload/Status Functions
-######################################################################
-start() {
-	if [ -e /proc/acpi ]; then
-		# call acpid with default config/logfiles
-		$daemon $options
-		return $?
-	fi
-}
-stop() {
-        pkill -o -x ${daemon##*/}
-        return $?
-}
-reload() {
-        pkill -HUP -o -x ${daemon##*/}
-        return $?
-}
-status() {
-        base=${daemon##*/}
-        dpid=`pidof -o $$ -o $PPID -o %PPID -x ${base}`
-        if [ "$dpid" != "" ]; then
-           echo "${base} (pid $dpid) is running..."
-        elif [ -s /var/run/${base}.pid ]; then
-           echo "${base} is dead but pid file exists..."
-        else
-           echo "${base} is stopped."
-        fi
-        return
-}
-######################################################################
-# See how we were called
-######################################################################
-case "$1" in
-       start) start      ;;
-        stop) stop       ;;
-      reload) reload     ;;
-     restart) stop;start ;;
-      status) status     ;;
-           *) echo "Usage: $0 {start|stop|reload|restart|status}" ; exit 1
+SSD=/sbin/start-stop-daemon
+PROG=/usr/sbin/acpid
+OPTS="-c ${CONFDIR} -L ${LCK} -p ${PID} -s ${SCK}"
+
+case "${1}" in
+start)
+	exec "${SSD}" --start --pidfile "${PID}" --exec "${PROG}" -- ${OPTS}
+	;;
+stop)
+	"${SSD}" --stop --retry 10 --pidfile "${PID}" --exec "${PROG}"
+	e=${?}
+	[ ${e} -eq 0 ] && rm -f ${RD}/acpid.socket
+	exit ${e}
+	;;
+reload)
+	"${SSD}" --status --pidfile "${PID}" --exec "${PROG}" &&
+		kill -HUP $(cat ${PID})
+	;;
+restart)
+	"${SSD}" --status --pidfile "${PID}" --exec "${PROG}" && "${0}" stop
+	exec "${0}" start
+	;;
+status)
+	"${SSD}" --status --pidfile "${PID}" --exec "${PROG}"
+	e=${?}
+	case ${e} in
+	0) echo "${PROG} is running with pid $(cat ${PID})";;
+	1) echo "${PROG} is not running but the pid file ${PID} exists";;
+	3) echo "${PROG} is not running";;
+	4) echo "Unable to determine the program status";;
+	esac
+	exit ${e}
+	;;
+*)
+	echo "usage: ${0} start|stop|reload|restart|status"
+	;;
 esac
-exit $?
diff --git a/acpid/default.sh b/acpid/default.sh
index 423bbff03..18bc18cb1 100644
--- a/acpid/default.sh
+++ b/acpid/default.sh
@@ -5,18 +5,28 @@ log() {
 	logger -t /etc/acpi/default.sh "${*}"
 }
 
+unhandled() {
+	t=${1}
+	shift
+	log "ACPI: no handler for event ${t}, data: ${*}";;
+
+}
+
 set ${*}
 
-# In order to not cumulate ACPI events actual actions should be detached
-# from/to /dev/null and backgrounded via &
-(
+# In order to not cumulate actions of ACPI event they should be detached via
+#	( ACTION ) </dev/null >/dev/null 2>&1 &
+# (At least setting volume or other things which depend on hardware which might
+# block and cause the script not to return for a while.)
 case "${1}" in
 button/power)
 	case "${2}" in
-	PWRF)	/sbin/init 0;;
-	*)	log "button/power action ${2} not handled (${*})";;
+	PWRF)
+		/sbin/init 0;;
+	*)
+		unhandled "${@}";;
 	esac
 	;;
-*)	log "ACPI group ${1} / action ${2} is not defined (${*})";;
+*)
+	unhandled;;
 esac
-) </dev/null >/dev/null 2>&1 &


More information about the crux-commits mailing list