May 8, 20197 yr 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!
May 12, 20197 yr 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
May 13, 20197 yr Author @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
May 14, 20197 yr Author @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, 20197 yr by fsix
July 8, 20223 yr 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
July 8, 20223 yr 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
October 16, 20223 yr 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, 20223 yr by solidno8
October 19, 2025Oct 19 Community Expert updated command for 7.1.4https://forums.unraid.net/topic/50490-solved-commands-to-start-and-stop-array/#findComment-1584966 7.1.4 1 line terminal command to stop the array... As if you hit the stop button on the main tabstop array:CSRF=$(grep -Po '^csrf_token="\K[^"]+' /var/local/emhttp/var.ini) # try HTTP first curl -sS -k --fail -e "http://localhost/Main" \ -c /tmp/unraid.cookies -b /tmp/unraid.cookies \ --data "startState=STARTED&file=&csrf_token=${CSRF}&cmdStop=Stop" \ http://localhost/update.htm || \ # fallback to HTTPS curl -sS -k --fail -e "https://localhost/Main" \ -c /tmp/unraid.cookies -b /tmp/unraid.cookies \ --data "startState=STARTED&file=&csrf_token=${CSRF}&cmdStop=Stop" \ https://localhost/update.htm stat array:CSRF=$(grep -Po '^csrf_token="\K[^"]+' /var/local/emhttp/var.ini) curl -sS -k --fail -e "http://localhost/Main" \ -c /tmp/unraid.cookies -b /tmp/unraid.cookies \ --data "startState=STOPPED&file=&csrf_token=${CSRF}&cmdStart=Start" \ http://localhost/update.htm || \ curl -sS -k --fail -e "https://localhost/Main" \ -c /tmp/unraid.cookies -b /tmp/unraid.cookies \ --data "startState=STOPPED&file=&csrf_token=${CSRF}&cmdStart=Start" \ https://localhost/update.htm *ASUMES A VALD ARRAY CONFIG!!!Verify and check:root@The-Borg:~# grep -E '^(mdState|fsState)=' /var/local/emhttp/var.inimdState="STARTED"fsState="Started"root@The-Borg:~#Why these parameters? Because the GUI’s JS adds a hidden cmdStop=Stop input and posts to /update.htm with csrf_token, plus a startState field (STARTED when stopping, STOPPED when starting) and an empty file param. Community-confirmed payloads (worked for others when GETs failed):Tested on the borg and saw array shuting down per web ui and array start per web ui...
April 4Apr 4 On 10/19/2025 at 11:24 PM, bmartino1 said:updated command for 7.1.4https://forums.unraid.net/topic/50490-solved-commands-to-start-and-stop-array/#findComment-15849667.1.4 1 line terminal command to stop the array... As if you hit the stop button on the main tabstop array:CSRF=$(grep -Po '^csrf_token="\K[^"]+' /var/local/emhttp/var.ini) # try HTTP first curl -sS -k --fail -e "http://localhost/Main" \ -c /tmp/unraid.cookies -b /tmp/unraid.cookies \ --data "startState=STARTED&file=&csrf_token=${CSRF}&cmdStop=Stop" \ http://localhost/update.htm || \ # fallback to HTTPS curl -sS -k --fail -e "https://localhost/Main" \ -c /tmp/unraid.cookies -b /tmp/unraid.cookies \ --data "startState=STARTED&file=&csrf_token=${CSRF}&cmdStop=Stop" \ https://localhost/update.htm stat array:CSRF=$(grep -Po '^csrf_token="\K[^"]+' /var/local/emhttp/var.ini) curl -sS -k --fail -e "http://localhost/Main" \ -c /tmp/unraid.cookies -b /tmp/unraid.cookies \ --data "startState=STOPPED&file=&csrf_token=${CSRF}&cmdStart=Start" \ http://localhost/update.htm || \ curl -sS -k --fail -e "https://localhost/Main" \ -c /tmp/unraid.cookies -b /tmp/unraid.cookies \ --data "startState=STOPPED&file=&csrf_token=${CSRF}&cmdStart=Start" \ https://localhost/update.htm *ASUMES A VALD ARRAY CONFIG!!!Verify and check:root@The-Borg:~# grep -E '^(mdState|fsState)=' /var/local/emhttp/var.inimdState="STARTED"fsState="Started"root@The-Borg:~#Why these parameters? Because the GUI’s JS adds a hidden cmdStop=Stop input and posts to /update.htm with csrf_token, plus a startState field (STARTED when stopping, STOPPED when starting) and an empty file param. Community-confirmed payloads (worked for others when GETs failed):Tested on the borg and saw array shuting down per web ui and array start per web ui...If using user script, we can't use just for 7.2.4 or 7.3betaX? emcmd cmdStart=Start
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.