fsix Posted May 8, 2019 Share Posted May 8, 2019 Since the dashboard now requires a csrf-token, the old wget-method does not work anymore: Is there any way to locally execute the array start/stop functions directly or is there a command for it? I have searched through tons of includes, php, template files and couldn't find where they actually execute it - besides all POSTing to the same endpoint. Of course a solution could be to have a headless browser or requests that regex out the csrf token prior, but it'd be much easier to just have something e.g. executed via ssh if available. Thank you in advanced! Quote Link to comment
Squid Posted May 12, 2019 Share Posted May 12, 2019 https://forums.unraid.net/topic/50490-solved-commands-to-start-and-stop-array/?tab=comments#comment-496967 But you'd first have to add in the csrf token to the end of the line ?csrf_token=xxxxxxxxxxxxxxx via whats listed in /var/local/emhttp/var.ini 1 Quote Link to comment
fsix Posted May 13, 2019 Author Share Posted May 13, 2019 @Squid Thanks! I guess it checks both for get and post values? because all forms I could find were doing a post exclusively. Based on what you said that should work, will try it in an hour or two to confirm: #!/bin/bash CSRF=$(cat /var/local/emhttp/var.ini | grep -oP 'csrf_token="\K[^"]+') wget -qO /dev/null http://localhost:$(lsof -nPc emhttp | grep -Po 'TCP[^\d]*\K\d+')/update.htm?cmdStart=Start&csrf_token=$CSRF Quote Link to comment
fsix Posted May 14, 2019 Author Share Posted May 14, 2019 (edited) @Squid Sadly didn't work, but the var.ini was the solution still! Start: #!/bin/bash CSRF=$(cat /var/local/emhttp/var.ini | grep -oP 'csrf_token="\K[^"]+') curl -k --data "startState=STOPPED&file=&csrf_token=${CSRF}&cmdStart=Start" http://localhost/update.htm Stop: #!/bin/bash CSRF=$(cat /var/local/emhttp/var.ini | grep -oP 'csrf_token="\K[^"]+') curl -k --data "startState=STARTED&file=&csrf_token=${CSRF}&cmdStop=Stop" http://localhost/update.htm Edited May 14, 2019 by fsix 2 Quote Link to comment
Isanderthul Posted July 8, 2022 Share Posted July 8, 2022 I needed to start the array from a different system, so I ended up doing this: #!/bin/bash CSRF=$(ssh [email protected] "sed -n 's/^csrf_token=//p' /var/local/emhttp/var.ini|tr -d '\"'") curl -k --data "startState=STOPPED&file=&csrf_token=${CSRF}&cmdStart=Start" http://192.168.88.235/update.htm Quote Link to comment
bonienl Posted July 8, 2022 Share Posted July 8, 2022 When using Unraid 6.10, you can simply use the following Start array #!/bin/bash emcmd cmdStart=Start Stop array #!/bin/bash emcmd cmdStop=Stop 3 Quote Link to comment
solidno8 Posted October 16, 2022 Share Posted October 16, 2022 (edited) Is there a way to define the keyfile when starting the array with emcmd cmdStart=Start? Staging the keyfile in /root before running the command doesn't seem to work Edited October 16, 2022 by solidno8 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.