Start/Stop Array via CLI


Recommended Posts

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!

Link to comment

@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

 

Link to comment

@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 by fsix
  • Like 2
Link to comment
  • 3 years later...
  • 3 months later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.