Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

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

Your result includes quotes. Do this:

array=$(grep -Po '^mdState="\K[^"]+' $var)

 

  • Author
1 hour ago, bonienl said:

Your result includes quotes. Do this:


array=$(grep -Po '^mdState="\K[^"]+' $var)

 

Thank you! @bonienl

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.