diff --git a/.gitattributes b/.gitattributes index bdb0cabc..1dc5631e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,5 @@ # Auto detect text files and perform LF normalization -* text=auto +* text=auto eol=lf # Custom for Visual Studio *.cs diff=csharp @@ -15,3 +15,6 @@ *.PDF diff=astextplain *.rtf diff=astextplain *.RTF diff=astextplain + +# Custom for PHP files with syntax highlighting +*.page text eol=lf lang=php diff --git a/.gitignore b/.gitignore index cd2946ad..1ddd0e02 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ Desktop.ini # Recycle Bin used on file shares $RECYCLE.BIN/ +# Updates by pr in new version +.updates.txt + # Windows Installer files *.cab *.msi diff --git a/README.md b/README.md index 1e208e7d..a34c5199 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,15 @@ For each file, if the file is not "in use" by any process (as detected by 'fuser If an error occurs in copying a file, the partial file, if present, is deleted and the operation continues on to the next file. ## Changelog +- 2025.02.18.1752 + - [Check parent empty ZFS dataset for children empty datasets before destroy it.](https://github.com/masterwishx/ca.mover.tuning/pull/1) ([masterwishx](https://github.com/masterwishx)) + - Shell Check Fixes + speedup `if` checks. + - Better help text cosmetic with Bold and italic + added note for Test Mode and some changes in config page. + - Skip cache pool size calculation when only one share found in cache pool. + - Changed minimum threshold of used Primary (cache) space from 5% to 0%. +- 2025.02.12.1707 + - [Fix issue for shares with spaces](https://github.com/R3yn4ld/ca.mover.tuning/pull/69) Thanks [DToX_](https://forums.unraid.net/topic/176951-mover-is-refusing-to-move-any-files-off-the-cache-from-a-share-with-a-space-in-the-name/#findComment-1521811) from forums. ([masterwishx](https://github.com/masterwishx)) + - [Add option to clean ZFS datasets](https://github.com/R3yn4ld/ca.mover.tuning/pull/69) ([masterwishx](https://github.com/masterwishx)) - 2024.09.05.0222 - [Fix find not finding hidden files](https://github.com/R3yn4ld/ca.mover.tuning/pull/67) Thanks to [solidno8](https://forums.unraid.net/topic/70783-plugin-mover-tuning/?do=findComment&comment=1461454) from forums. ([R3yn4ld](https://github.com/R3yn4ld)) - 2024.09.05.0115 @@ -166,3 +175,4 @@ See the [Mover Tuning_ thread on the Unraid support forum](https://forums.unraid ## Thanks This was originally created by [Squid](https://github.com/Squidly271) and updated by [hugenbd](https://github.com/hugenbd/ca.mover.tuning), with contributions by [Castcore](https://github.com/Castcore), [Swarles](https://github.com/hugenbd/ca.mover.tuning/commit/64e06e91bd83431d768346e4d8158f7be039564e), [Dphelan](https://github.com/dphelan) and [Davendsai](https://github.com/davendesai). +@2025 Updated by [masterwishx](https://github.com/masterwishx/ca.mover.tuning). \ No newline at end of file diff --git a/archive/ca.mover.tuning-2025.02.12.1707-x86_64-1.txz b/archive/ca.mover.tuning-2025.02.12.1707-x86_64-1.txz new file mode 100644 index 00000000..55d9d31b Binary files /dev/null and b/archive/ca.mover.tuning-2025.02.12.1707-x86_64-1.txz differ diff --git a/archive/ca.mover.tuning-2025.02.18.1752-x86_64-1.txz b/archive/ca.mover.tuning-2025.02.18.1752-x86_64-1.txz new file mode 100644 index 00000000..dcead52d Binary files /dev/null and b/archive/ca.mover.tuning-2025.02.18.1752-x86_64-1.txz differ diff --git a/plugins/ca.mover.tuning.plg b/plugins/ca.mover.tuning.plg index f2f40e5b..efbeca72 100644 --- a/plugins/ca.mover.tuning.plg +++ b/plugins/ca.mover.tuning.plg @@ -1,12 +1,12 @@ - - - + + + - + @@ -15,6 +15,17 @@ +###2025.02.18.1752 +- [Check parent empty ZFS dataset for children empty datasets before destroy it.](https://github.com/masterwishx/ca.mover.tuning/pull/1) ([masterwishx](https://github.com/masterwishx)) +- Shell Check Fixes + speedup `if` checks. +- Better help text cosmetic with Bold and italic + added note for Test Mode and some changes in config page. +- Skip cache pool size calculation when only one share found in cache pool. +- Changed minimum threshold of used Primary (cache) space from 5% to 0%. + +###2025.02.12.1707 +- Fix issue for shares with spaces.Thanks DToX_ from forums. [masterwishx] +- Add option to clean ZFS datasets. [masterwishx] + ###2024.09.05.0222 - Fix find not finding hidden files. Thanks solidno8 from forums. [R3yn4ld] 2024.09.05.0115 diff --git a/source/ca.mover.tuning/pkg_build.sh b/source/ca.mover.tuning/pkg_build.sh index eae59e56..1f3a2253 100755 --- a/source/ca.mover.tuning/pkg_build.sh +++ b/source/ca.mover.tuning/pkg_build.sh @@ -1,21 +1,72 @@ #!/bin/bash + +# Get the directory of the script DIR="$(dirname "$(readlink -f ${BASH_SOURCE[0]})")" + +# Set the temporary directory and plugin name tmpdir=/tmp/tmp.$(( $RANDOM * 19318203981230 + 40 )) plugin=$(basename ${DIR}) archive="$(dirname $(dirname ${DIR}))/archive" -version=$(date +"%Y.%m.%d.%H%M")$1 -config_file=/mnt/cache/appdata/Development/github-desktop/GitHub/ca.mover.tuning//plugins/ca.mover.tuning.plg +# $2 is argument addition to date (a,b,c) +version=$(date +"%Y.%m.%d")$2 +# $1 Path to the plugin directory +config_file="$1/ca.mover.tuning/plugins/ca.mover.tuning.plg" +readme_file="$1/ca.mover.tuning/README.md" +# Create the temporary directory and copy files mkdir -p $tmpdir +# Get the content from .update file +update_content="$(dirname $(dirname "$DIR"))/.updates.txt" + cp --parents -f $(find . -type f ! \( -iname "pkg_build.sh" -o -iname "sftp-config.json" \) ) $tmpdir/ + cd $tmpdir + +# Build the package using makepkg makepkg -l y -c y ${archive}/${plugin}-${version}-x86_64-1.txz -rm -rf $tmpdir + +# Calculate the MD5 hash of the package package_md5=$(md5sum ${archive}/${plugin}-${version}-x86_64-1.txz | awk '{print $1}') + echo "Version: $version" echo "MD5: $package_md5" echo "" +echo "Update Content: $update_content" +echo "" echo "Updating ca.mover.plugin.plg" +echo "Updating README.md" + sed -i "s//" "$config_file" -sed -i "s//" "$config_file" \ No newline at end of file +sed -i "s//" "$config_file" + +# Define variables for your files and version +tmp_config_file="$tmpdir/tmp_config_file.txt" +tmp_readme_file="$tmpdir/tmp_readme_file.txt" + +# Modify the config file (*.plg) with changelog +# Step 1: Cut content after ### from $config_file to $tmp_config_file +sed -n '/###*/,$p' "$config_file" > "$tmp_config_file" +# Step 2: Dlete evrything after ### in $config_file +sed -i '/###*/,$d' "$config_file" +# Step 3: Add version to $config_file +sed -i '$a\###'${version}'' "$config_file" +# Step 4: Add content from $update_content to $config_file +cat "$update_content" >> "$config_file"; echo -e "\n" >> "$config_file" +# Step 5: Add content from $tmp_config_file to $config_file +cat "$tmp_config_file" >> "$config_file" + +# Modify the readme file with changelog +# Step 1: Cut content after ## Changelog from $readme_file to $tmp_readme_file +sed -n '/- 20*/,$p' "$readme_file" > "$tmp_readme_file" +# Step 2: Dlete evrything after ## Changelog in $readme_file +sed -i '/- 20*/,$d' "$readme_file" +# Step 3: Add version to $readme_file +sed -i '$a\- '${version}'' "$readme_file" +# Step 4: Add content from $update_content to $readme_file +cat "$update_content" | sed -e 's/^/ /' >> "$readme_file"; echo -e "\n" >> "$readme_file" +# Step 5: Add content from $tmp_readme_file to $readme_file +cat "$tmp_readme_file" >> "$readme_file" + +# Clean up the temporary directory +rm -rf $tmpdir diff --git a/source/ca.mover.tuning/usr/local/emhttp/plugins/ca.mover.tuning/Mover.tuning.page b/source/ca.mover.tuning/usr/local/emhttp/plugins/ca.mover.tuning/Mover.tuning.page index 1eec858d..2086ef65 100644 --- a/source/ca.mover.tuning/usr/local/emhttp/plugins/ca.mover.tuning/Mover.tuning.page +++ b/source/ca.mover.tuning/usr/local/emhttp/plugins/ca.mover.tuning/Mover.tuning.page @@ -110,9 +110,9 @@ Disable Mover running on a schedule: -* Note that setting this to yes effectively disables this plugin +Yes - setting effectively disables this plugin -> This will prevent mover from running at the schedule set in Mover Settings. You will only be able to run mover by manually invoking it. +> This will prevent mover from running at the schedule set in Mover Settings. You will only be able to run mover by manually invoking it.
Test Mode (dry run): @@ -120,8 +120,9 @@ Test Mode (dry run): +No - setting effectively disables test mode -> Test Mode will not run mover but will output the custom find command results to /tmp/ca.mover.tuning/. Caution - If you have "Move Now button follows plug-in filters" set to no, original Mover will still run. +> Test Mode will Not run mover but will output the custom find command results to /tmp/ca.mover.tuning/. Caution - If you have "Move Now button follows plug-in filters" set to No, original Mover will still run. Log Mover Tuning plugin actions : -> Enables or disables logging from this plugin. Logs are displayed in syslog and stored at /tmp/ca.mover.tuning +> Enables or disables logging from this plugin. Logs are displayed in syslog and stored at /tmp/ca.mover.tuning Show advanced settings: : ' > -> Cron Schedule entry example 20 4 1 * * To run the first day of the month at 4:20 AM +> Cron Schedule entry example 20 4 1 * *. To run the first day of the month at 4:20 AM Allow force mover schedule to run during a parity check/rebuild: : -> Select yes to to follow plug-in filters, no to run original mover from button. +> Select Yes to to follow plug-in filters, No to run original mover from button.
Filters
Only move if above this threshold of used Primary (cache) space: : @@ -251,7 +252,7 @@ Move files that are greater than this many days old: -'Auto' setting enable smart caching +Auto - setting enable smart caching > Select the number of days old a file has to be in order to move (Up To 1 year). Auto will move from the oldest to the most recent, until threshold is met. @@ -305,7 +306,7 @@ Move files off Primary (cache) based on sparseness? -> Select the sparseness size. Any file with a sparseness larger will be moved. +> Select the sparseness size. Any file with a sparseness larger will be moved. Move files that are greather than this sparseness: : > Very few will use this, keep set to No. -> Removes any files or directories that start with a . -> Adds -not -path '*/\.*' to the end of the find command. +> Removes any files or directories that start with a . +> Adds -not -path '*/\.*' to the end of the find command. Move All from Primary->Secondary (cache:yes) shares when disk is above a certain percentage: : -> Set to "Yes" if you want to move all files from a Primary->Secondary (cache:yes) share to the array if the percentage below is exceeded. This is similar to the original mover and does not apply any filters from this plug-in to the find command sent to the mover binary. +> Set to "Yes" if you want to move all files from a Primary->Secondary (cache:yes) share to the array if the percentage below is exceeded. This is similar to the original mover and does not apply any filters from this plug-in to the find command sent to the mover binary. Move All from Primary->Secondary shares pool percentage: : -> Set to the amount of disk space used on the Primary pool to initiate a move of all files in a Primary->Secondary (cache:yes) share. Filters will still run after, for any remaining pool's that do not meet this threshold. This threshold should at a minimum be 5% larger than "Only move at this threshold of used primary (cache) space:" above. +> Set to the amount of disk space used on the Primary pool to initiate a move of all files in a Primary->Secondary (cache:yes) share. Filters will still run after, for any remaining pool's that do not meet this threshold. This threshold should at a minimum be 5% larger than "Only move at this threshold of used primary (cache) space:" above. @@ -390,7 +391,16 @@ Clean empty folders -> This will clean the parent folder (only) of moved file. +> This will remove the parent folder only of moved files. + +Clean empty ZFS datasets +: + +> This will unmount and destroy the parent ZFS dataset on share of moved files, only if not contain child datasets within. + Synchronize Primary files to Secondary :