You are not logged in.
Pages: 1
Hello:
My /proc/acpi/wakeup file reads thus:
groucho@devuan:/proc/acpi$ cat wakeup
Device S-state Status Sysfs node
USB0 S4 *enabled pci:0000:00:1d.0
USB1 S4 *enabled pci:0000:00:1d.1
USB2 S4 *enabled pci:0000:00:1d.2
USB5 S4 *disabled
EUSB S4 *enabled pci:0000:00:1d.7
USB3 S4 *enabled pci:0000:00:1a.0
USB4 S4 *enabled pci:0000:00:1a.1
USB6 S4 *enabled pci:0000:00:1a.2
USBE S4 *enabled pci:0000:00:1a.7
P0P1 S4 *disabled pci:0000:00:01.0
P0P2 S4 *disabled pci:0000:00:06.0
P0P3 S4 *disabled pci:0000:00:1c.0
BR11 S4 *disabled
BR12 S4 *disabled
BR13 S4 *disabled
P0P4 S4 *disabled pci:0000:00:1c.4
BR15 S4 *disabled
P0P5 S4 *disabled pci:0000:00:1e.0
GBE S4 *enabled pci:0000:00:19.0
SLPB S4 *disabled
groucho@devuan:/proc/acpi$
I have no use for anything being enabled there and found a script to set everything to 'disabled':
See: https://gist.github.com/npcardoso/47d8f … wakeups-sh
#!/bin/bash
if [[ $# > 1 || ($1 != "enable" && $1 != "disable") ]]; then
echo "Usage: $0 <enable|disable>"
exit 1
fi
if [[ $1 == "enable" ]]; then
TOGGLE=grep '\*disabled' /proc/acpi/wakeup | cut -d ' ' -f1
else
TOGGLE=grep '\*enabled' /proc/acpi/wakeup | cut -d ' ' -f1
fi
for DEV in $TOGGLE; do
echo $DEV
echo $DEV > /proc/acpi/wakeup
done
For some reason it is not running properly.
groucho@devuan:~$ ./acpi_wakeups.sh disable
./acpi_wakeups.sh: line 14: \*enabled: command not found
groucho@devuan:~$
groucho@devuan:~$ ./acpi_wakeups.sh enable
./acpi_wakeups.sh: line 10: \*disabled: command not found
groucho@devuan:~$
Any help would be appreciated.
Thanks in advance,
A.
Last edited by Altoid (2021-04-14 15:05:09)
Offline
Hello:
... need to be run as the root user?
Yes, of course.
groucho@devuan:~$ sudo ./acpi_wakeups.sh enable
./acpi_wakeups.sh: line 10: \*disabled: command not found
groucho@devuan:~$
groucho@devuan:~$ sudo ./acpi_wakeups.sh disable
./acpi_wakeups.sh: line 14: \*enabled: command not found
groucho@devuan:~$
Just in case ...
[root@devuan ~]# /home/groucho/acpi_wakeups.sh enable
/home/groucho/acpi_wakeups.sh: line 10: \*disabled: command not found
[root@devuan ~]#
[root@devuan ~]# /home/groucho/acpi_wakeups.sh disable
/home/groucho/acpi_wakeups.sh: line 14: \*enabled: command not found
[root@devuan ~]#
Thanks for your input.
Best,
A.
Offline
https://gist.github.com/npcardoso/47d8f … wakeups-sh has backticks round grep '\*disabled' /proc/acpi/wakeup | cut -d ' ' -f1 and grep '\*enabled' /proc/acpi/wakeup | cut -d ' ' -f1. Those tell bash to run the command inside the backticks and assign the output from it to TOGGLE.
You could use $(...) instead, it's easier to read if you don't get muddled about what sort of brackets to use.
Chris
Offline
Use https://www.shellcheck.net/ to test scripts. That would have identified the problem along with several other issues.
Better version:
#!/bin/sh
if [ $# -gt 1 ] || [ "$1" != enable ] && [ "$1" != disable ]; then
echo "Usage: $0 <enable|disable>"
exit 1
fi
if [ "$1" = enable ]; then
TOGGLE=$(grep '\*disabled' /proc/acpi/wakeup | cut -d ' ' -f1)
else
TOGGLE=$(grep '\*enabled' /proc/acpi/wakeup | cut -d ' ' -f1)
fi
for DEV in $TOGGLE ; do
echo "$DEV"
echo "$DEV" > /proc/acpi/wakeup
done
POSIX sh ftw!
It can be simplified further if all you want to do is disable everything:
#!/bin/sh
dev=$(awk '/*enabled/{print $1}' /proc/acpi/wakeup)
for i in $dev ; do
echo "$i" > /proc/acpi/wakeup
done
Brianna Ghey — Rest In Power
Offline
Hello:
... use $(...) instead, it's easier to read if you don't get muddled about what sort of brackets to use.
I am not the author of the script.
Unfortunately, I don't have a clue as to how this all works.
Thanks for your input.
Best,
A.
Offline
Hello:
Use https://www.shellcheck.net/ to test scripts.
Thanks for the heads up.
Will bookmark that one for the next time.
Being a script from github, I assumed an error of some sort at my end.
As it seemed harmess enough, I just copied it, made it executable and tried it.
Never thought it would have a problem.
Better version:
#!/bin/sh if [ $# -gt 1 ] || [ "$1" != enable ] && [ "$1" != disable ]; then echo "Usage: $0 <enable|disable>" exit 1 fi if [ "$1" = enable ]; then TOGGLE=$(grep '\*disabled' /proc/acpi/wakeup | cut -d ' ' -f1) else TOGGLE=$(grep '\*enabled' /proc/acpi/wakeup | cut -d ' ' -f1) fi for DEV in $TOGGLE ; do echo "$DEV" echo "$DEV" > /proc/acpi/wakeup done
Right.
POSIX sh ftw!
Don't quite follow you, but I'll take your word for it. 8^)
... simplified further if all you want to do is disable everything:
Yes, that would be much better.
These /proc/acpi/wakeup settings are from S4, which my box doesn't ever/won't ever go into.
And seeing how flaky ACPI tables can be, it's better to keep this disabled.
#!/bin/sh dev=$(awk '/*enabled/{print $1}' /proc/acpi/wakeup) for i in $dev ; do echo "$i" > /proc/acpi/wakeup done
Works a charm! 8^D
groucho@devuan:~$ sudo ./acpi_wakeups.sh
[sudo] password for groucho:
groucho@devuan:~$
groucho@devuan:~$ cat /proc/acpi/wakeup
Device S-state Status Sysfs node
USB0 S4 *disabled pci:0000:00:1d.0
USB1 S4 *disabled pci:0000:00:1d.1
USB2 S4 *disabled pci:0000:00:1d.2
USB5 S4 *disabled
EUSB S4 *disabled pci:0000:00:1d.7
USB3 S4 *disabled pci:0000:00:1a.0
USB4 S4 *disabled pci:0000:00:1a.1
USB6 S4 *disabled pci:0000:00:1a.2
USBE S4 *disabled pci:0000:00:1a.7
P0P1 S4 *disabled pci:0000:00:01.0
P0P2 S4 *disabled pci:0000:00:06.0
P0P3 S4 *disabled pci:0000:00:1c.0
BR11 S4 *disabled
BR12 S4 *disabled
BR13 S4 *disabled
P0P4 S4 *disabled pci:0000:00:1c.4
BR15 S4 *disabled
P0P5 S4 *disabled pci:0000:00:1e.0
GBE S4 *disabled pci:0000:00:19.0
SLPB S4 *disabled
groucho@devuan:~$
Thank you very much for your input.
Best,
A.
Offline
Never thought it would have a problem.
The script on GitHub does actually have the backticks, you must have missed them when you copied it.
Head_on_a_Stick wrote:POSIX sh ftw!
Don't quite follow you
The original script used bash but didn't contain anything that actually needed bash. The tests ([[...]]) were the bash version but the /bin/sh (POSIX) test ([...]) works just as well. I always prefer /bin/sh over /bin/bash because it's faster, lighter and less buggy. The Debian developers also prefer /bin/sh for the same reasons and went to quite some effort replacing all of the bash system scripts with /bin/sh versions. Ubuntu also did this: https://wiki.ubuntu.com/DashAsBinSh
Last edited by Head_on_a_Stick (2021-04-14 19:12:43)
Brianna Ghey — Rest In Power
Offline
Hello:
... you must have missed them when you copied it.
Painted short, probably?
Have to be more careful.
... script used bash but didn't contain anything that actually needed bash.
I see.
... prefer /bin/sh over /bin/bash because it's faster, lighter and less buggy.
The Debian developers also prefer /bin/sh for the same reasons and went to quite some effort replacing all of the bash system scripts with /bin/sh versions.
Kudos to them.
Thanks for taking the time to explain.
Best,
A.
Offline
Pages: 1