Skip to content

Commit

Permalink
process SnapRAID info at the right time
Browse files Browse the repository at this point in the history
Process snapraid info in the script after the config file has been found
  • Loading branch information
auanasgheps authored Nov 19, 2024
1 parent 48cc6ed commit ea237a4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion snapraid-aio-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ fi
fi
fi

# Extract SnapRAID info (content and parity files) from the config file
extract_snapraid_info

# sanity check first to make sure we can access the content and parity files
mklog "INFO: Checking SnapRAID disks"
Expand Down Expand Up @@ -1110,7 +1112,6 @@ result=$?
if [ $result -eq 0 ]; then
# Only one SnapRAID config file found, proceeding
echo "Proceeding with the omv-snapraid-.conf file: $SNAPRAID_CONF"

elif [ $result -eq 2 ]; then
# Multiple SnapRAID config files found, stopping the script
echo "Stopping the script due to multiple SnapRAID configuration files. Please choose one config file and update your settings in the script-config file at ""$CONFIG_FILE"". Available SnapRAID config files:"
Expand Down Expand Up @@ -1163,6 +1164,25 @@ search_conf_files() {
fi
}

# Extract SnapRAID info (content and parity files) from the config file

extract_snapraid_info() {
# Extract info from SnapRAID config
SNAPRAID_CONF_LINES=$(grep -E '^[^#;]' $SNAPRAID_CONF)

IFS=$'\n'
# Build an array of content files
CONTENT_FILES=(
$(echo "$SNAPRAID_CONF_LINES" | grep snapraid.content | cut -d ' ' -f2)
)

# Build an array of parity all files...
PARITY_FILES=(
$(echo "$SNAPRAID_CONF_LINES" | grep -E '^([2-6z]-)*parity' | cut -d ' ' -f2- | tr ',' '\n')
)
unset IFS
}

# Run SnapRAID status to check for the previous sync
check_snapraid_status() {
# Run snapraid status command and capture the output
Expand Down

0 comments on commit ea237a4

Please sign in to comment.