[CLOSED] Script Help - Var.ini and 6.4.0-rc10


Recommended Posts

I used to have a script that would check if the array was started and parity check was not running before backing up files. Using:

#!/bin/bash

var=/proc/mdcmd
array=$(grep -Po '^mdState=\K\S+' $var)
rsync=$(grep -Po '^mdResync=\K\S+' $var)

if [[ $array == STARTED && $rsync -eq 0 ]]; then
    rysnc script
fi

 

I saw that from rc8 onwards the preferred method to read array status is by quering the var.ini and disks.ini files.

 

so I updated the a test script to the following:

#!/bin/bash

var=/var/local/emhttp/var.ini
array=$(grep -Po '^mdState=\K\S+' $var)
rsync=$(grep -Po '^mdResync=\K\S+' $var)

echo $array
echo $rsync

if [[ $array == STARTED ]];
then
	echo "ARRAY STARTED"
else
	echo "ARRARY NOT STARTED"
fi

if [[ $rsync -eq 0 ]];
then
	echo "RSYNC 0"
else
	echo "RSYNC Running"
fi

and my output is:

"STARTED"
"0"
ARRARY NOT STARTED
./test: line 17: [[: "0": syntax error: operand expected (error token is ""0"")
RSYNC Running

Does anyone know why the if else logic is coming back false instead of true like the echo variables are stating?

Edited by archedraft
Link to comment

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.