busybox: add power safe and reboot safe scripts for the MCA
This commit adds power safe and reboot safe script for the MCA and substitute default reboot and poweroff busybox commands. Signed-off-by: Mike Engel <Mike.Engel@digi.com> https://onedigi.atlassian.net/browse/DEL-7828
This commit is contained in:
parent
c29c47e3a0
commit
d3b7fca933
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#===============================================================================
|
||||||
|
#
|
||||||
|
# poweroff_safe
|
||||||
|
#
|
||||||
|
# Copyright (C) 2022 by Digi International Inc.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU General Public License version 2 as published by
|
||||||
|
# the Free Software Foundation.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# !Description: safe power-off script
|
||||||
|
#
|
||||||
|
#===============================================================================
|
||||||
|
|
||||||
|
scriptname="$(basename "$(readlink -f "${0}")")"
|
||||||
|
pwroff_safe="$(find /sys/devices/ -name pwroff_safe 2>/dev/null)"
|
||||||
|
|
||||||
|
# Default timeout 30s
|
||||||
|
TOUT="30"
|
||||||
|
UNLOCK_STR="CTRU"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
printf "\nInitiates a power-off on the system and programs the MCA"
|
||||||
|
printf "\nto force an immediate power-off after a configured timeout."
|
||||||
|
printf "\nThis assures the system will power off even if the"
|
||||||
|
printf "\nsystem hangs during regular shut down process."
|
||||||
|
printf "\nUsage: %s [OPTIONS]\n
|
||||||
|
-t timeout value in seconds (30 seconds by default)
|
||||||
|
-h Show this help
|
||||||
|
\n" "${scriptname}"
|
||||||
|
}
|
||||||
|
|
||||||
|
while getopts "t:h" c; do
|
||||||
|
case "${c}" in
|
||||||
|
h) usage; exit;;
|
||||||
|
t) TOUT=${OPTARG};;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -f "${pwroff_safe}" ]; then
|
||||||
|
# Configure the MCA to power off after ${TOUT} seconds
|
||||||
|
echo "${UNLOCK_STR}${TOUT}" > "${pwroff_safe}"
|
||||||
|
else
|
||||||
|
printf "\nSafe power-off operation not supported. Proceeding with a regular power-off\n\n"
|
||||||
|
exec poweroff
|
||||||
|
fi
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#===============================================================================
|
||||||
|
#
|
||||||
|
# reboot_safe
|
||||||
|
#
|
||||||
|
# Copyright (C) 2022 by Digi International Inc.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU General Public License version 2 as published by
|
||||||
|
# the Free Software Foundation.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# !Description: safe reboot script
|
||||||
|
#
|
||||||
|
#===============================================================================
|
||||||
|
|
||||||
|
scriptname="$(basename "$(readlink -f "${0}")")"
|
||||||
|
reboot_safe="$(find /sys/devices/ -name reboot_safe 2>/dev/null)"
|
||||||
|
|
||||||
|
# Default timeout 30s
|
||||||
|
TOUT="30"
|
||||||
|
UNLOCK_STR="CTRU"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
printf "\nInitiates a reboot of the system and programs the MCA"
|
||||||
|
printf "\nto force an immediate reset after a configured timeout."
|
||||||
|
printf "\nThis assures the system will reset even if the"
|
||||||
|
printf "\nsystem hangs during regular reboot process."
|
||||||
|
printf "\nUsage: %s [OPTIONS]\n
|
||||||
|
-t timeout value in seconds (30 seconds by default)
|
||||||
|
-h Show this help
|
||||||
|
\n" "${scriptname}"
|
||||||
|
}
|
||||||
|
|
||||||
|
while getopts "t:h" c; do
|
||||||
|
case "${c}" in
|
||||||
|
h) usage; exit;;
|
||||||
|
t) TOUT=${OPTARG};;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -f "${reboot_safe}" ]; then
|
||||||
|
# Configure the MCA to reboot after ${TOUT} seconds
|
||||||
|
echo "${UNLOCK_STR}${TOUT}" > "${reboot_safe}"
|
||||||
|
else
|
||||||
|
printf "\nSafe reboot operation not supported. Proceeding with a regular reboot\n\n"
|
||||||
|
exec reboot
|
||||||
|
fi
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Copyright (C) 2013-2019 Digi International.
|
# Copyright (C) 2013-2022 Digi International.
|
||||||
|
|
||||||
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
|
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
|
||||||
|
|
||||||
|
|
@ -13,6 +13,9 @@ SRC_URI += "file://standby \
|
||||||
file://pswitch-standby \
|
file://pswitch-standby \
|
||||||
file://pswitch-poweroff \
|
file://pswitch-poweroff \
|
||||||
file://bridgeifupdown \
|
file://bridgeifupdown \
|
||||||
|
${@bb.utils.contains("MACHINE_FEATURES", "mca", "file://poweroff_safe \
|
||||||
|
file://reboot_safe \
|
||||||
|
", "", d)} \
|
||||||
"
|
"
|
||||||
|
|
||||||
SRC_URI_append_ccimx6ul = " file://index.html \
|
SRC_URI_append_ccimx6ul = " file://index.html \
|
||||||
|
|
@ -20,6 +23,7 @@ SRC_URI_append_ccimx6ul = " file://index.html \
|
||||||
"
|
"
|
||||||
|
|
||||||
HAS_SYSTEMD = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}"
|
HAS_SYSTEMD = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}"
|
||||||
|
HAS_MCA = "${@bb.utils.contains('MACHINE_FEATURES', 'mca', 'true', 'false', d)}"
|
||||||
|
|
||||||
# hwclock bootscript init parameters
|
# hwclock bootscript init parameters
|
||||||
INITSCRIPT_PARAMS_${PN}-hwclock = "start 20 S . stop 20 0 6 ."
|
INITSCRIPT_PARAMS_${PN}-hwclock = "start 20 S . stop 20 0 6 ."
|
||||||
|
|
@ -91,6 +95,12 @@ do_install_append() {
|
||||||
install -m 0755 ${WORKDIR}/bridgeifupdown ${D}${sysconfdir}/network/if-pre-up.d/
|
install -m 0755 ${WORKDIR}/bridgeifupdown ${D}${sysconfdir}/network/if-pre-up.d/
|
||||||
ln -s ../if-pre-up.d/bridgeifupdown ${D}${sysconfdir}/network/if-post-down.d/bridgeifupdown
|
ln -s ../if-pre-up.d/bridgeifupdown ${D}${sysconfdir}/network/if-post-down.d/bridgeifupdown
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# install MCA power safe and reboot safe scripts
|
||||||
|
if ${HAS_MCA}; then
|
||||||
|
install -m 0755 ${WORKDIR}/poweroff_safe ${D}${base_bindir}/poweroff_safe
|
||||||
|
install -m 0755 ${WORKDIR}/reboot_safe ${D}${base_bindir}/reboot_safe
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
do_install_append_ccimx6ul() {
|
do_install_append_ccimx6ul() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue