OPNsense Forum

English Forums => 24.7, 24.10 Legacy Series => Topic started by: imk82 on August 20, 2024, 03:23:02 PM

Title: [SOLVED] configctl action throws "Action not allowed or missing" error message
Post by: imk82 on August 20, 2024, 03:23:02 PM
Hi all,

I try to setup a simple cronjob via UI. Unfortunately, I don't get the syntax for creating a respective action.

What I tried:
* read https://docs.opnsense.org/development/backend/configd.html
* created a file "actions_set_powersave_nvme.conf" under "/usr/local/opnsense/service/conf/actions.d"
* see content below
* restarted configd

My problem now is, when I try to test/start it via
configctl actions_set_powersave_nvme restart
I get the following error message:
Action not allowed or missing

Can anyone help me to find my mistake?

Thanks and best regards
Robert

Content of actions_set_powersave_nvme.conf:

[restart]
command:/sbin/nvmecontrol power -p 4 nvme0
parameters:
type:script
message:Setting nvme0 to powerstate 4
description:Set nvme disk 0 to power state 4
Title: Re: Need help creating a action for a cron job
Post by: chemlud on August 20, 2024, 04:46:59 PM
http://kb.unixservertech.com/other/networking/opnsense/cron-jobs

Afterwards configure your cron jobs in GUI with new entry in drop-down menu under

System -> Settings -> Cron


What happens if you enter command directly in the console?
Title: Re: Need help creating a action for a cron job
Post by: imk82 on August 20, 2024, 07:54:23 PM
QuoteWhat happens if you enter command directly in the console?

If I execute the command directly via console all is fine and working:
root@jupiter:~ # /sbin/nvmecontrol power -p 4 nvme0
root@jupiter:~ # echo $?
0
root@jupiter:~ # /sbin/nvmecontrol power nvme0
Current Power State is 4
Current Workload Hint is 0


I can select the action as well via Web GUI. But it is not working and in the console I see the error when trying to run it via configctl.

Action not allowed or missing
Title: Re: Need help creating a action for a cron job
Post by: imk82 on August 21, 2024, 01:20:47 PM
Ok, after digging a little deeper into the topic and the respective python code, it seems to be a generic error if the the action is not found which can have multiple reasons.

The most obvious one in my case is the leading actions_ in my configctl call which is plain wrong. Just for the notes, a call to configctl action ... or similar is as well not supported, same for a fullqualified path to the action.

So to sum up, what works a the end is:

/usr/local/opnsense/service/conf/actions.d/actions_nvmepowersave.conf:

[start]
command:/sbin/nvmecontrol power -p 4 nvme0
parameters:
type:script
message:Setting nvme0 to powerstate 4
description:Set nvme disk 0 to power state 4


working test call:

root@jupiter:~ # service configd restart
Stopping configd...done
Starting configd.
root@jupiter:~ # configctl nvmepowersave start
OK