I have got a .sh-script, trying to make powertop changes permanent.
'auto' > '/sys/bus/pci/devices/0000:00:02.1/power/control';
the commands in this .sh-script are all of this type.
I have a systemd-service in /etc/systemd/system with this content:
[Unit]
Description=My Script
After=network.target
[Service]
Type=forking
ExecStart=/home/my_username/.autostart_sudo.sh
[Install]
WantedBy=multi-user.target
The script ".autostart_sudo.sh" is called correctly after boot, (for example "bluetooth off"-command in this file is called perfeclty) but the echo->-commands are not called successfully.
I noticed that typing
sudo 'auto' > '/sys/bus/pci/devices/0000:00:02.1/power/control';
in a terminal gives a restriction-error, but
sudo su
'auto' > '/sys/bus/pci/devices/0000:00:02.1/power/control';
works.
how do I have to change my systemd+bash-script to get the powertop-changes working on boot?
Thanks in advance!
Edit:
Okay, I try to describe the flow again: I got the systemd service posted on top of this post. This service calls the ".autostart_sudo.sh" in my /home/user/.
There are plenty commands in this .autostart_sudo.sh looking like this:
echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.2/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:04:00.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:03:00.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:1a.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:03.3/power/control';
(...)
thinkfan start
The "thinkfan start" needs also root-privileges to start correctly, this one works, but the "echo"-commands dont.
I also tryed
bash -c 'echo auto > /sys/bus/pci/devices/0000:00:1d.0/power/control;'
bash -c 'echo auto > /sys/bus/pci/devices/0000:00:1a.7/power/control;'
bash -c 'echo auto > /sys/bus/pci/devices/0000:00:1a.2/power/control;'
bash -c 'echo auto > /sys/bus/pci/devices/0000:00:02.0/power/control;'
bash -c 'echo auto > /sys/bus/pci/devices/0000:00:02.1/power/control;'
doesnt work either :/
The sudo-test-stuff I mentioned above were just tests in a Terminal.
any advice?
'auto' > '/sys/bus/pci/devices/0000:00:02.1/power/control'
in your script orecho 'auto' > '/sys/bus/pci/devices/0000:00:02.1/power/control'
? In any case, if your script is called by systemd,sudo
should not be necessary. Dows it work if you justecho
the commands into the files, with nosudo
?echo 'auto' | sudo tee 'file'
work?