I used to just edit the rc.local file and add a line of code to it but now rc.local is ignored how do I use the following line to change the fan speed? I have changed it manually but after each reboot the speeds change back to default which is why I had the edit to rc.local.
How do I keep the temp_levels file edited or at least edit it every startup again?
Hmm DietPi does not use rc.local anymore for its own scripts, but we don’t touch it’s finality. But on default Raspbian/Debian images it might be not enabled.
Please check/assure that rc-local.service is enacted and rc.local executable:
systemctl enable rc-local
chmod +x /etc/rc.local
cat /etc/rc.local
#!/bin/sh -e
#
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to disable this script please use systemd to control the service:
# systemctl disable rc-local.service
#
# By default this script does nothing.
echo "40 50 65" > /sys/devices/odroid_fan.*/temp_levels
exit 0
ls -lah /etc/rc.local
-rwxr-xr-x 1 root root 387 Mar 14 21:28 /etc/rc.local
service rc-local status
● rc-local.service - rc.local backwards compatibility
Loaded: loaded (/etc/systemd/system/rc-local.service; enabled)
Active: active (exited) (Result: exit-code) since Sat 2018-03-17 14:39:51 ACDT; 1 day 19h ago
Process: 1133 ExecStart=/bin/bash -c /etc/rc.local (code=exited, status=2)
Main PID: 1133 (code=exited, status=2)
CGroup: /system.slice/rc-local.service
Mar 17 14:39:51 DietPi systemd[1]: Started rc.local backwards compatibility.
Mar 17 14:39:51 DietPi systemd[1]: rc-local.service: main process exited, code=exited, status=2/INVALIDARGUMENT
That is everything. Sorry it isn’t neat. As for the temp_levels file I have edited that and need to every restart.
root@Odroid-HC1:~# nano /etc/rc.local
#!/bin/sh -e
#
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to disable this script please use systemd to control the service:
# systemctl disable rc-local.service
#
# By default this script does nothing.
## Message-start:
echo "\n - setting Custom Temp. Levels for Fan Speed ... "
## set Custom Temp. Levels for Fan Speed
echo "40 50 65" > /sys/devices/odroid_fan.14/temp_levels
## Message-finish:
echo " - Done! -\n"
exit 0
I noticed the echo. Please be aware my script used to work and I do not have any screen attached. I use it as a server. I don’t think that will help in my exact circumstance.
Is rc.local even being used any more? If not why change anything to do with it at all? If it’s no longer being used then wouldn’t I need to change something in whatever has replaced it?
No need to be like that. I don’t know much at all about any of what you wrote and that echo line stood out. I was checking that it wouldn’t cause any issues. If it did I wouldn’t be able to fix and would lose an entire day re-installing my server.
Keeping in mind that I have no gui or screen and only ever access via ssh when needed which of the 2 preposed solutions do you think would work for me?
rc.local is natively integrated into Debian, though by default on new Debian images not activated. systemctl enable rc-local and making /etc/rc.local an executable file with exit 0 at the end, does the job.
DietPi used rc.local for own scripts until v6.2, thus all our images have an already enabled/functional rc.local implemented. From v6.3 we switched to an own service for DietPi scripts, but left rc.local in place for users who used it for their own scripts as well.
From v6.5 on fresh images will not touch rc.local (nor the underlying services) at all, thus in most cases users need to enable it by themselves. But this doesn’t effect existing/upgraded servers.
And back to your issue:
It is indeed the wildcard “*” within echo target file name. I just tried it on my Stretch VM an found exactly the same error message, where without wildcard it worked well .
So depending on if the fan device has fixed or not, go with k-plans or my last command suggestion.
But according to the error message I still believe the command inside your script has some syntax error. Could you provide your /etc/rc.local again? Then I can test here.
#!/bin/sh -e
#
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to disable this script please use systemd to control the service:
# systemctl disable rc-local.service
#
# By default this script does nothing.
echo "40 50 65" > /sys/devices/odroid_fan.*/temp_levels
exit 0
That is the same line that worked in 4.x. I have no idea about coding. What I have found is a manually edit the temp_levels file the fan speeds fix themselves. The problem is that no matter what rc.local seems to be completely ignored now. every reboot I manually nano that file and taadaa it’s fixed. I need the temp lower because plex will easily overheat it otherwise.
/bin/bash does parse those wildcards, but /bin/sh does not:
root@DietPi:~# l test7/test
-rw-r–r-- 1 root root 11 Mar 30 13:40 test7/test
root@DietPi:~# cat test7/test
no success
root@DietPi:~# /bin/sh -c “echo ‘success’ > test*/test”
/bin/sh: 1: cannot create test*/test: Directory nonexistent
root@DietPi:~# cat test7/test
no success
root@DietPi:~# /bin/bash -c “echo ‘success’ > test*/test”
root@DietPi:~# cat test7/test
success
As we reverted to Debian default rc.local file, it was reverted to /bin/sh:
root@DietPi:~# cat /etc/rc.local
#!/bin/sh -e
…
Jep we should have thought about this, as our own rc.local script used bash and user commands can rely on this shell.
But as you can see your rc.local is not ignored, it does indeed contain a syntax issue/not parsed wildcard by changed shell.
But why insisting in using your old command? Why not just avoid wildcard by giving known fixed folder name or use my method above? Both works well with bourne shell:
for file in /sys/devices/odroid_fan.*/temp_levels
do
echo ‘40 50 65’ > “$file”
done
Otherwise switch back to “#!/bin/bash -e” with rc.local.