mirror of
https://github.com/rootzoll/raspiblitz.git
synced 2025-02-28 16:58:03 +01:00
3114 poweroff improve (#4287)
This commit is contained in:
parent
2896fa398a
commit
16b3afe0ab
1 changed files with 16 additions and 2 deletions
|
@ -16,7 +16,7 @@ if [ "$1" = "reboot" ]; then
|
||||||
/home/admin/_cache.sh set state "reboot"
|
/home/admin/_cache.sh set state "reboot"
|
||||||
/home/admin/_cache.sh set message "$2"
|
/home/admin/_cache.sh set message "$2"
|
||||||
else
|
else
|
||||||
shutdownParams="-h now"
|
shutdownParams="-P -h now"
|
||||||
echo "Then wait 5 seconds and disconnect power."
|
echo "Then wait 5 seconds and disconnect power."
|
||||||
/home/admin/_cache.sh set state "shutdown"
|
/home/admin/_cache.sh set state "shutdown"
|
||||||
/home/admin/_cache.sh set message ""
|
/home/admin/_cache.sh set message ""
|
||||||
|
@ -75,10 +75,24 @@ if [ "${isBTRFS}" == "1" ] && [ "${isMounted}" == "1" ]; then
|
||||||
fi
|
fi
|
||||||
sync
|
sync
|
||||||
|
|
||||||
|
# unmount HDD - try to kill all processes first #3114
|
||||||
|
echo "# Killing the processes using /mnt/hdd"
|
||||||
|
processesUsingDisk=$(sudo lsof -t "/mnt/hdd")
|
||||||
|
while [ -n "$processesUsingDisk" ]; do
|
||||||
|
pid=$(echo "$processesUsingDisk" | head -n 1)
|
||||||
|
processName=$(ps -p $pid -o comm=)
|
||||||
|
echo "# Stop $processName with: 'kill -SIGTERM $pid'"
|
||||||
|
sudo kill -SIGTERM $pid # Send SIGTERM signal
|
||||||
|
sleep 5 # Wait for the process to terminate
|
||||||
|
processesUsingDisk=$(sudo lsof -t "/mnt/hdd") # Refresh the list
|
||||||
|
done
|
||||||
|
echo "# Attempt to unmount /mnt/hdd"
|
||||||
|
sudo umount "/mnt/hdd"
|
||||||
|
|
||||||
echo "starting shutdown ..."
|
echo "starting shutdown ..."
|
||||||
sudo shutdown ${shutdownParams}
|
sudo shutdown ${shutdownParams}
|
||||||
|
|
||||||
# detect missing DBUS
|
# detect missing DBUS
|
||||||
if [ "${DBUS_SESSION_BUS_ADDRESS}" == "" ]; then
|
if [ "${DBUS_SESSION_BUS_ADDRESS}" == "" ]; then
|
||||||
echo "WARN: Missing \$DBUS_SESSION_BUS_ADDRESS .. "
|
echo "WARN: Missing \$DBUS_SESSION_BUS_ADDRESS .. "
|
||||||
if [ "$1" = "reboot" ]; then
|
if [ "$1" = "reboot" ]; then
|
||||||
|
|
Loading…
Add table
Reference in a new issue