The officially official Devuan Forum!

You are not logged in.

#1 2021-08-31 20:32:15

xsR_head
Member
Registered: 2021-08-24
Posts: 13  

[SOLVED] How to run a root command on startup?

Hello, I want the following command to run at system startup:
echo XHC1 > /proc/acpi/wakeup
I have a sysvinit initialisation system. As far as I understand I need to create a script and place it in /etc/init.d/ then run sudo update-rc.d 'service name' defaults. I created a simple bash script:
#!/bin/bash
echo XHC1 > /proc/acpi/wakeup
but it seems that I am doing something wrong since the update-rc.d command shows error when I add the script to default run level, and the script doesn't execute for some reason.
Best regards

P.S
As far as I understand the script should be compliant to some sysvinit syntax, but I can't figure what are the exact rules.

Last edited by xsR_head (2021-08-31 21:19:44)

Offline

#2 2021-08-31 21:07:50

Dutch_Master
Member
Registered: 2018-05-31
Posts: 206  

Re: [SOLVED] How to run a root command on startup?

You use SysVinit, but issue commands for OpenRC? Best read up on boot scripts for sysvinit then tongue Also, it's best practice to end a script with

exit 0

HTH!

Online

#3 2021-08-31 21:17:48

xsR_head
Member
Registered: 2021-08-24
Posts: 13  

Re: [SOLVED] How to run a root command on startup?

I am pretty sure you are confusing sysvinit update-rc.d with OpenRC rc-update.
P.S I previously used OpenRC on Artix smile

Last edited by xsR_head (2021-08-31 21:20:51)

Offline

#4 2021-08-31 21:43:58

xsR_head
Member
Registered: 2021-08-24
Posts: 13  

Re: [SOLVED] How to run a root command on startup?

Aight, I think I figured it out, looking at other scripts. Gonna mark the question as [SOLVED] when done.

Offline

#5 2021-08-31 22:46:21

xsR_head
Member
Registered: 2021-08-24
Posts: 13  

Re: [SOLVED] How to run a root command on startup?

Aight, here is the script (I used manual for 'init-d-script' for syntax man init-d-script):

#!/bin/bash
### BEGIN INIT INFO
# Provides:          dead_XHC1
# Required-Start: $all
# Required-Stop:  
# Default-Start:  2 
# Default-Stop:   
# Short-Description: Disable wake on XHC1
# Description:       Disable wake on XHC1
#                  
### END INIT INFO
echo XHC1 > /proc/acpi/wakeup
exit 0

Then I made it executable

chmod +x /etc/init.d/dead_XHC1

Then added to the service list

sudo update-rc.d 'dead_XHC1' defaults

P.S:
Btw, this script fixes not properly working suspend on lid close for certain laptops that have issue with brcfmac driver.
You might want to play around with what device you need to disable; The enabled devices available at:

cat /proc/acpi/wakeup

Hope this will help someone, coz I spend days trying to figure out what's wrong with suspend.

Last edited by xsR_head (2021-08-31 22:57:50)

Offline

#6 2021-09-01 00:35:10

sgage
Member
Registered: 2016-12-01
Posts: 287  

Re: [SOLVED] How to run a root command on startup?

I would just stick it in /etc/rc.local. I do a similar thing to defeat the power-saving on my sound card, which makes nasty pops:

#!/bin/bash
echo 0 > /sys/module/snd_hda_intel/parameters/power_save
exit 0

Offline

Board footer