Skip to content

Commit 6637cc6

Browse files
authored
Merge pull request #120 from DonkeeeyKong/dev
Add the option to execute the last custom hook before spinning down drives
2 parents b991ef5 + 32436b3 commit 6637cc6

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

script-config.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,12 @@ BEFORE_HOOK_CMD=""
226226
# last command.
227227
# This option does not have any effect if CUSTOM_HOOK is set to 0
228228
# Use NAME for a friendly name, CMD for the command itself.
229+
# Set EXECUTE_BEFORE_SPINDOWN to 1, if you have hd-idle configured
230+
# to spin down your disks in the end and want the custom hook to be
231+
# executed before that. Default is execution after spindown.
229232
AFTER_HOOK_NAME=""
230233
AFTER_HOOK_CMD=""
234+
EXECUTE_BEFORE_SPINDOWN=0
231235

232236
####################### USER CONFIGURATION END #######################
233237

snapraid-aio-script.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,12 @@ if [ "$SNAP_STATUS" -eq 1 ]; then
311311
fi
312312
fi
313313

314+
# Custom Hook - After (if executed before drive spin down)
315+
if [ "$CUSTOM_HOOK" -eq 1 ] && [ "$EXECUTE_BEFORE_SPINDOWN" -eq 1 ]; then
316+
echo "### Custom Hook - [$AFTER_HOOK_NAME]";
317+
bash -c "$AFTER_HOOK_CMD"
318+
fi
319+
314320
# Spin down disks (Method hd-idle - spins down all rotational devices)
315321
# NOTE: Uses hd-idle rewrite
316322

@@ -332,7 +338,7 @@ fi
332338
fi
333339

334340
# Custom Hook - After
335-
if [ "$CUSTOM_HOOK" -eq 1 ]; then
341+
if [ "$CUSTOM_HOOK" -eq 1 ] && [ "$EXECUTE_BEFORE_SPINDOWN" -ne 1 ]; then
336342
echo "### Custom Hook - [$AFTER_HOOK_NAME]";
337343
bash -c "$AFTER_HOOK_CMD"
338344
fi

0 commit comments

Comments
 (0)