Skip to content

Commit ea237a4

Browse files
authored
process SnapRAID info at the right time
Process snapraid info in the script after the config file has been found
1 parent 48cc6ed commit ea237a4

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

snapraid-aio-script.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ fi
157157
fi
158158
fi
159159

160+
# Extract SnapRAID info (content and parity files) from the config file
161+
extract_snapraid_info
160162

161163
# sanity check first to make sure we can access the content and parity files
162164
mklog "INFO: Checking SnapRAID disks"
@@ -1110,7 +1112,6 @@ result=$?
11101112
if [ $result -eq 0 ]; then
11111113
# Only one SnapRAID config file found, proceeding
11121114
echo "Proceeding with the omv-snapraid-.conf file: $SNAPRAID_CONF"
1113-
11141115
elif [ $result -eq 2 ]; then
11151116
# Multiple SnapRAID config files found, stopping the script
11161117
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:"
@@ -1163,6 +1164,25 @@ search_conf_files() {
11631164
fi
11641165
}
11651166

1167+
# Extract SnapRAID info (content and parity files) from the config file
1168+
1169+
extract_snapraid_info() {
1170+
# Extract info from SnapRAID config
1171+
SNAPRAID_CONF_LINES=$(grep -E '^[^#;]' $SNAPRAID_CONF)
1172+
1173+
IFS=$'\n'
1174+
# Build an array of content files
1175+
CONTENT_FILES=(
1176+
$(echo "$SNAPRAID_CONF_LINES" | grep snapraid.content | cut -d ' ' -f2)
1177+
)
1178+
1179+
# Build an array of parity all files...
1180+
PARITY_FILES=(
1181+
$(echo "$SNAPRAID_CONF_LINES" | grep -E '^([2-6z]-)*parity' | cut -d ' ' -f2- | tr ',' '\n')
1182+
)
1183+
unset IFS
1184+
}
1185+
11661186
# Run SnapRAID status to check for the previous sync
11671187
check_snapraid_status() {
11681188
# Run snapraid status command and capture the output

0 commit comments

Comments
 (0)