-
Notifications
You must be signed in to change notification settings - Fork 4
Dev-new-fixes-22 #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev-new-fixes-22 #108
Changes from all commits
5b6b484
3ed2832
9305d28
9be34d4
38b0b57
fb93aa2
679fe8d
5e81e92
c947dee
9f3576f
8b7581d
12a8598
1f51d38
29dfdbf
a3885b4
751077e
5420496
92236be
63ac40f
7a5b07f
04f5bfb
2a2bfd1
f72d460
71d9855
fdaf3c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -387,6 +387,26 @@ | |||||||||||||||||||||||||
| echo "********************************************************************\n"; | ||||||||||||||||||||||||||
| exit(1); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // NEW: Breaking-changes notice for Unraid >= 7.2.1 | ||||||||||||||||||||||||||
| if ( version_compare($version['version'], "7.2.1", ">=") ) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| echo "=============================================================\n"; | ||||||||||||||||||||||||||
| echo " IMPORTANT: Starting with Unraid 7.2.1, Mover Tuning behavior\n"; | ||||||||||||||||||||||||||
| echo " has changed:\n"; | ||||||||||||||||||||||||||
| echo " ------------------------------------------------------------\n"; | ||||||||||||||||||||||||||
| echo " • The plugin is now separated from the built-in Unraid mover.\n"; | ||||||||||||||||||||||||||
| echo " • “Move Now” in Mover Settings runs the built-in Unraid mover.\n"; | ||||||||||||||||||||||||||
| echo " • “Move” on the Main page also runs the Unraid mover.\n"; | ||||||||||||||||||||||||||
| echo " • “Move Now” in Mover Tuning → Options runs age_mover.\n"; | ||||||||||||||||||||||||||
| echo " • To disable the built-in mover schedule, set it to Disabled\n"; | ||||||||||||||||||||||||||
| echo " in Mover Settings.\n"; | ||||||||||||||||||||||||||
| echo " • Use the “Mover Tuning Schedule” (Plugin Settings) to\n"; | ||||||||||||||||||||||||||
| echo " schedule Mover Tuning instead.\n"; | ||||||||||||||||||||||||||
| echo " • The Unraid mover can still be triggered through the\n"; | ||||||||||||||||||||||||||
| echo " “Force move all files on a schedule” option.\n"; | ||||||||||||||||||||||||||
| echo "=============================================================\n\n"; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| ?> | ||||||||||||||||||||||||||
| ]]> | ||||||||||||||||||||||||||
| </INLINE> | ||||||||||||||||||||||||||
|
|
@@ -414,45 +434,15 @@ The 'post-install' script | |||||||||||||||||||||||||
| <FILE Run="/bin/bash"> | ||||||||||||||||||||||||||
| <INLINE> | ||||||||||||||||||||||||||
| echo "" | ||||||||||||||||||||||||||
| if [[ -e /usr/local/sbin/mover ]]; then | ||||||||||||||||||||||||||
| if [[ ! -f /usr/local/sbin/mover.old ]]; then | ||||||||||||||||||||||||||
| echo "Backing up current /usr/local/sbin/mover script" | ||||||||||||||||||||||||||
| mv /usr/local/sbin/mover /usr/local/sbin/mover.old | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
| elif [[ -e /usr/local/bin/mover ]]; then | ||||||||||||||||||||||||||
| if [[ ! -f /usr/local/bin/mover.old ]]; then | ||||||||||||||||||||||||||
| echo "Backing up current /usr/local/bin/mover script" | ||||||||||||||||||||||||||
| mv /usr/local/bin/mover /usr/local/bin/mover.old | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
| echo "Installing tuned mover script" | ||||||||||||||||||||||||||
| cp /usr/local/emhttp/plugins/&name;/mover /usr/local/sbin/mover | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Cleaning eventual leftovers | ||||||||||||||||||||||||||
| if ! pgrep age_mover; then | ||||||||||||||||||||||||||
| echo "Cleaning lock and stop files" | ||||||||||||||||||||||||||
| for file in mover.pid moversoft.stop; do | ||||||||||||||||||||||||||
| if [[ -e "/var/run/$file" ]]; then rm -f "/var/run/$file"; fi | ||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Renaming mover.cron.disabled to mover.cron if exists (from old cron fix) | ||||||||||||||||||||||||||
| if [[ -e /boot/config/plugins/dynamix/mover.cron.disabled ]]; then mv -f /boot/config/plugins/dynamix/mover.cron.disabled /boot/config/plugins/dynamix/mover.cron; fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| echo "Fixing permissions" | ||||||||||||||||||||||||||
| chmod +x /usr/local/sbin/mover | ||||||||||||||||||||||||||
| chmod +x /usr/local/emhttp/plugins/ca.mover.tuning/*.php | ||||||||||||||||||||||||||
| chmod +x /usr/local/emhttp/plugins/ca.mover.tuning/age_mover | ||||||||||||||||||||||||||
| chmod +x /usr/local/emhttp/plugins/ca.mover.tuning/mover | ||||||||||||||||||||||||||
| chmod +x /usr/local/emhttp/plugins/ca.mover.tuning/share_mover | ||||||||||||||||||||||||||
| chmod +x /usr/local/emhttp/plugins/ca.mover.tuning/debug_mover | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Config file | ||||||||||||||||||||||||||
| config_file=/boot/config/plugins/&name;/&name;.cfg; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if [[ $(cat $config_file | wc -l) -eq 1 ]]; then | ||||||||||||||||||||||||||
| rm $config_file | ||||||||||||||||||||||||||
| # Remove legacy single-line configs if present | ||||||||||||||||||||||||||
| if [[ -f "$config_file" && $(wc -l < "$config_file") -eq 1 ]]; then | ||||||||||||||||||||||||||
| rm "$config_file" | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if [[ ! -f "$config_file" ]]; then | ||||||||||||||||||||||||||
| echo "Creating file $config_file with default configuration." | ||||||||||||||||||||||||||
| # Create the file with some default values | ||||||||||||||||||||||||||
|
|
@@ -493,6 +483,105 @@ else | |||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Read Unraid version | ||||||||||||||||||||||||||
| UNRAID_VERSION=$(grep '^version=' /etc/unraid-version | cut -d'"' -f2) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Safe version compare function (no symbols that break XML) | ||||||||||||||||||||||||||
| version_ge() { | ||||||||||||||||||||||||||
| [ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$2" ] | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| echo "Unraid version detected: $UNRAID_VERSION" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Backup built-in mover ONLY on older Unraid | ||||||||||||||||||||||||||
| if version_ge "$UNRAID_VERSION" "7.2.1"; then | ||||||||||||||||||||||||||
| echo "Unraid 7.2.1 or newer — skipping mover script backup." | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| TUNING_CRON_FILE="/boot/config/plugins/&name;/mover.tuning.cron" | ||||||||||||||||||||||||||
| DYNAMIX_CRON_FILE="/boot/config/plugins/dynamix/mover.cron" | ||||||||||||||||||||||||||
| DYNAMIX_CRON_OLD="/boot/config/plugins/dynamix/mover.cron.old" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Only perform migration if mover.tuning.cron does NOT exist | ||||||||||||||||||||||||||
| # AND old dynamix/mover.cron exists | ||||||||||||||||||||||||||
| if [[ ! -f "$TUNING_CRON_FILE" && -f "$DYNAMIX_CRON_FILE" ]]; then | ||||||||||||||||||||||||||
| echo "Detected old Unraid mover schedule — migrating into Mover Tuning." | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Read value from var.ini | ||||||||||||||||||||||||||
| SHARE_MOV_SCHED=$(grep '^shareMoverSchedule=' /var/local/emhttp/var.ini | cut -d'"' -f2) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if [[ -n "$SHARE_MOV_SCHED" ]]; then | ||||||||||||||||||||||||||
| echo "Found shareMoverSchedule: $SHARE_MOV_SCHED" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Add moverTuneCron only if missing | ||||||||||||||||||||||||||
| if [[ -f "$config_file" ]] && grep -q '^moverTuneCron=' "$config_file"; then | ||||||||||||||||||||||||||
| echo "moverTuneCron already exists — skipping update." | ||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||
| # Only append if file exists | ||||||||||||||||||||||||||
| echo "Setting moverTuneCron to: $SHARE_MOV_SCHED" | ||||||||||||||||||||||||||
| if [[ -f "$config_file" ]]; then | ||||||||||||||||||||||||||
| echo "moverTuneCron=\"$SHARE_MOV_SCHED\"" >> "$config_file" | ||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||
| echo "Config file not found." | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Create cron file for Mover Tuning | ||||||||||||||||||||||||||
| echo "Creating Mover Tuning cron file: $TUNING_CRON_FILE" | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| echo "# Generated schedule for Mover Tuning move:" | ||||||||||||||||||||||||||
| echo "$SHARE_MOV_SCHED /usr/local/emhttp/plugins/ca.mover.tuning/age_mover start |& logger -t move" | ||||||||||||||||||||||||||
| } > "$TUNING_CRON_FILE" | ||||||||||||||||||||||||||
|
Comment on lines
+528
to
+533
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bash-specific syntax in cron command may fail. The cron command on line 532 uses Apply this diff to use POSIX-compatible syntax: echo "Creating Mover Tuning cron file: $TUNING_CRON_FILE"
{
echo "# Generated schedule for Mover Tuning move:"
- echo "$SHARE_MOV_SCHED /usr/local/emhttp/plugins/ca.mover.tuning/age_mover start |& logger -t move"
+ echo "$SHARE_MOV_SCHED /usr/local/emhttp/plugins/ca.mover.tuning/age_mover start 2>&1 | logger -t move"
} > "$TUNING_CRON_FILE"Note: 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||
| echo "shareMoverSchedule is empty — nothing to migrate." | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Rename old dynamix cron file | ||||||||||||||||||||||||||
| echo "Renaming old schedule: mover.cron → mover.cron.old" | ||||||||||||||||||||||||||
| mv "$DYNAMIX_CRON_FILE" "$DYNAMIX_CRON_OLD" | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||
| echo "Unraid version below 7.2.1 — performing mover script backup." | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if [[ -e /usr/local/sbin/mover ]]; then | ||||||||||||||||||||||||||
| if [[ ! -f /usr/local/sbin/mover.old ]]; then | ||||||||||||||||||||||||||
| echo "Backing up /usr/local/sbin/mover" | ||||||||||||||||||||||||||
| mv /usr/local/sbin/mover /usr/local/sbin/mover.old | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| elif [[ -e /usr/local/bin/mover ]]; then | ||||||||||||||||||||||||||
| if [[ ! -f /usr/local/bin/mover.old ]]; then | ||||||||||||||||||||||||||
| echo "Backing up /usr/local/bin/mover" | ||||||||||||||||||||||||||
| mv /usr/local/bin/mover /usr/local/bin/mover.old | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| echo "Installing tuned mover script" | ||||||||||||||||||||||||||
| cp /usr/local/emhttp/plugins/&name;/mover /usr/local/sbin/mover | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| echo "Fixing permissions for mover" | ||||||||||||||||||||||||||
| chmod +x /usr/local/sbin/mover | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Cleaning eventual leftovers | ||||||||||||||||||||||||||
| if ! pgrep age_mover; then | ||||||||||||||||||||||||||
| echo "Cleaning lock and stop files" | ||||||||||||||||||||||||||
| for file in mover.pid moversoft.stop; do | ||||||||||||||||||||||||||
| if [[ -e "/var/run/$file" ]]; then rm -f "/var/run/$file"; fi | ||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Renaming mover.cron.disabled to mover.cron if exists (from old cron fix) | ||||||||||||||||||||||||||
| if [[ -e /boot/config/plugins/dynamix/mover.cron.disabled ]]; then mv -f /boot/config/plugins/dynamix/mover.cron.disabled /boot/config/plugins/dynamix/mover.cron; fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| echo "Fixing permissions for ca.mover.tuning files" | ||||||||||||||||||||||||||
| chmod +x /usr/local/emhttp/plugins/ca.mover.tuning/*.php | ||||||||||||||||||||||||||
| chmod +x /usr/local/emhttp/plugins/ca.mover.tuning/age_mover | ||||||||||||||||||||||||||
| chmod +x /usr/local/emhttp/plugins/ca.mover.tuning/mover | ||||||||||||||||||||||||||
| chmod +x /usr/local/emhttp/plugins/ca.mover.tuning/share_mover | ||||||||||||||||||||||||||
| chmod +x /usr/local/emhttp/plugins/ca.mover.tuning/debug_mover | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| echo "" | ||||||||||||||||||||||||||
| echo "----------------------------------------------------" | ||||||||||||||||||||||||||
| echo " &name; has been installed." | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,7 @@ if ($var['shareCacheEnabled']!='yes') { | |||||||||||||||||
| } elseif ($var['shareUser']=='-') { | ||||||||||||||||||
| echo "<p class='notice'>User shares not enabled!</p>"; | ||||||||||||||||||
| } | ||||||||||||||||||
| $vars = @parse_ini_file("/var/local/emhttp/var.ini") ?: []; | ||||||||||||||||||
| $plugin = 'ca.mover.tuning'; | ||||||||||||||||||
| $config_file = '/boot/config/plugins/' . $plugin . '/' . $plugin . '.cfg'; | ||||||||||||||||||
| $config_default_file = '/usr/local/emhttp/plugins/' . $plugin . '/default.cfg'; | ||||||||||||||||||
|
|
@@ -30,6 +31,8 @@ $sizefDisabled = ($cfg['sizef'] != "yes") ? "disabled" : ""; | |||||||||||||||||
| $sizefSyncDisabled = ($cfg['sizefSync'] != "yes") ? "disabled" : ""; | ||||||||||||||||||
| $sparsnessfDisabled = ($cfg['sparsnessf'] != "yes") ? "disabled" : ""; | ||||||||||||||||||
| $version = ($cfg['version']); | ||||||||||||||||||
| $moverRunning = file_exists('/var/run/mover.pid'); | ||||||||||||||||||
| $showMoverButton = version_compare($vars['version'] ?? '0.0.0', '7.2.1', '>='); | ||||||||||||||||||
|
|
||||||||||||||||||
| ?> | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -49,15 +52,20 @@ $.fn.toggleAttr = function(attr) { | |||||||||||||||||
|
|
||||||||||||||||||
| function updateCron() { | ||||||||||||||||||
| var cron = $("#cronSchedule").val(); | ||||||||||||||||||
| var tune_cron = $("#tune_cronSchedule").val(); | ||||||||||||||||||
| var cronEnabled = $("#forceCron").val(); | ||||||||||||||||||
| var ismoverDisabled = $("#moverDisabled").val(); | ||||||||||||||||||
| $.post("/plugins/ca.mover.tuning/updateCron.php",{cronEnabled:cronEnabled,cron:cron,ismoverDisabled:ismoverDisabled}); | ||||||||||||||||||
| $.post("/plugins/ca.mover.tuning/updateCron.php",{cronEnabled:cronEnabled,cron:cron,tune_cron:tune_cron,ismoverDisabled:ismoverDisabled}); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| function moveNow() { | ||||||||||||||||||
| $.post("/plugins/ca.mover.tuning/mover.php crond start"); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| function startTuneMover() { | ||||||||||||||||||
| $.post("/plugins/ca.mover.tuning/mover.php", { cmdStartTuneMover: 1 }); | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+65
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The Consider using a callback or promise to reload after the POST completes: function startTuneMover() {
-$.post("/plugins/ca.mover.tuning/mover.php", { cmdStartTuneMover: 1 });
+$.post("/plugins/ca.mover.tuning/mover.php", { cmdStartTuneMover: 1 }, function() {
+ location.reload();
+});
}Then update line 787: -<input type="button" name="StartTuneMover" value="_(Move now)_" onclick="startTuneMover(); location.reload()" ...>
+<input type="button" name="StartTuneMover" value="_(Move now)_" onclick="startTuneMover()" ...>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| function resetDefaults() { | ||||||||||||||||||
| $.post("/plugins/ca.mover.tuning/reset.php"); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
@@ -126,6 +134,66 @@ $(function() { | |||||||||||||||||
| }); | ||||||||||||||||||
| </script> | ||||||||||||||||||
|
|
||||||||||||||||||
| <!-- Condition A: Unraid native Mover schedule enabled --> | ||||||||||||||||||
| <span id="mover_schedule_warning" class="orange-text" | ||||||||||||||||||
| style="display:<?= (!empty($vars['shareMoverSchedule']) && version_compare($vars['version'], '7.2.1', '>=')) ? 'block' : 'none' ?>; font-style:italic;"> | ||||||||||||||||||
| <i class="fa fa-warning"></i> | ||||||||||||||||||
| <?= _('Unraid Mover schedule is currently') ?> <b>enabled</b> | ||||||||||||||||||
| (<?= htmlspecialchars($vars['shareMoverSchedule']) ?>). | ||||||||||||||||||
| <?= _('If you want Mover Tuning to fully manage scheduling, disable it in Mover Settings.') ?> | ||||||||||||||||||
| </span> | ||||||||||||||||||
|
|
||||||||||||||||||
| <!-- Breaking changes notice for Unraid 7.2.1+ --> | ||||||||||||||||||
| <div id="mover_tuning_breaking_notice" | ||||||||||||||||||
| style="display:<?= (version_compare($vars['version'], '7.2.1', '>=')) ? 'block' : 'none' ?>; | ||||||||||||||||||
| position:relative; | ||||||||||||||||||
| background-color: var(--title-header-background-color); | ||||||||||||||||||
| border: 1px solid var(--border-color); | ||||||||||||||||||
| border-radius:10px; | ||||||||||||||||||
| box-shadow: 0.05em 0.2em 0.6em var(--dynamix-awesomplete-list-shadow-color); | ||||||||||||||||||
| padding:15px 40px 15px 15px; | ||||||||||||||||||
| margin-bottom:10px; | ||||||||||||||||||
| color:var(--ui-info); | ||||||||||||||||||
| font-size:1.5rem; | ||||||||||||||||||
| line-height:1.5em;"> | ||||||||||||||||||
| <i class="fa fa-info-circle" style="margin-right:5px;"></i> | ||||||||||||||||||
| <?= _('**Important: *Starting with Unraid 7.2.1, Mover Tuning plugin behavior has changed:***') ?> | ||||||||||||||||||
| <br><br> | ||||||||||||||||||
| <?= _('• The plugin is now separated from the built-in Unraid mover.') ?> | ||||||||||||||||||
| <br> | ||||||||||||||||||
| <?= _('• **“Move Now”** in the main Mover Settings runs the built-in Unraid mover.') ?> | ||||||||||||||||||
| <br> | ||||||||||||||||||
| <?= _('• **“Move”** on the Main page also runs the built-in Unraid mover.') ?> | ||||||||||||||||||
| <br> | ||||||||||||||||||
| <?= _('• **“Move Now”** in Mover Tuning → Options runs the plugin age_mover (Mover Tuning).') ?> | ||||||||||||||||||
| <br> | ||||||||||||||||||
| <?= _('• To disable the built-in Unraid mover schedule, set **“Mover schedule”** in Mover Settings to **Disabled**.') ?> | ||||||||||||||||||
| <br> | ||||||||||||||||||
| <?= _('• Use the **“Mover Tuning Schedule”** in the plugin settings to schedule **Mover Tuning** instead.') ?> | ||||||||||||||||||
| <br> | ||||||||||||||||||
| <?= _('• The built-in Unraid mover can still be triggered using **“Force move all files on a schedule”** (Cron schedule) in Plugin Settings if needed.') ?> | ||||||||||||||||||
|
|
||||||||||||||||||
| <!-- Close button --> | ||||||||||||||||||
| <span id="close_mover_notice" | ||||||||||||||||||
| class="fa fa-times" | ||||||||||||||||||
| style="position:absolute; top:5px; right:10px; cursor:pointer; font-size:1.3rem;" | ||||||||||||||||||
| title="Close"></span> | ||||||||||||||||||
| </div> | ||||||||||||||||||
|
|
||||||||||||||||||
| <script> | ||||||||||||||||||
| document.getElementById('close_mover_notice').addEventListener('click', function() { | ||||||||||||||||||
| var notice = document.getElementById('mover_tuning_breaking_notice'); | ||||||||||||||||||
| notice.style.display = 'none'; | ||||||||||||||||||
| localStorage.setItem('mover_notice_closed', 'yes'); | ||||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
| // Hide automatically if previously closed | ||||||||||||||||||
| if (localStorage.getItem('mover_notice_closed') === 'yes') { | ||||||||||||||||||
| var notice = document.getElementById('mover_tuning_breaking_notice'); | ||||||||||||||||||
| notice.style.display = 'none'; | ||||||||||||||||||
| } | ||||||||||||||||||
| </script> | ||||||||||||||||||
|
|
||||||||||||||||||
| <div class="title"> | ||||||||||||||||||
| <span class="left"><i class="fa fa-cog title"></i>Mover Tuning - Plugin Settings</span> | ||||||||||||||||||
| <span class="right">Version: <?=$version?></span> | ||||||||||||||||||
|
|
@@ -147,6 +215,16 @@ _(Disable Mover running on a schedule)_: | |||||||||||||||||
| :end | ||||||||||||||||||
|
|
||||||||||||||||||
| <div markdown="1" id="moverTuningSettings"> | ||||||||||||||||||
| <?php if (version_compare($vars['version'], '7.2.1', '>=')): ?> | ||||||||||||||||||
| _(Mover Tuning schedule)_: | ||||||||||||||||||
| : <input type='text' id='tune_cronSchedule' name='moverTuneCron' size='1' class='tune_mycron' placeholder='0 */4 * * *' value='<?=htmlspecialchars($cfg['moverTuneCron'])?>'> | ||||||||||||||||||
|
|
||||||||||||||||||
| <blockquote class="inline_help"> | ||||||||||||||||||
| <p>Runs the <strong><code>age_mover</code></strong> schedule from the Mover Tuning plugin using your custom cron entry (includes all plugin filters).</p> | ||||||||||||||||||
| <p> Cron Schedule entry example <strong>0 */4 * * *</strong>. To run at <em>every</em><strong> 4 hours</strong>. <a href="https://crontab.guru/" target="_blank" rel="noopener noreferrer"><i class="fa fa-clock-o"></i> What Is Cron</a></p> | ||||||||||||||||||
| </blockquote> | ||||||||||||||||||
| <?php endif; ?> | ||||||||||||||||||
|
|
||||||||||||||||||
| _(Test Mode (dry run))_: | ||||||||||||||||||
| : <select name='testmode' size='1' id='testmode' onchange="toggleTestModeWarning(this.value)"> | ||||||||||||||||||
| <?=mk_option($cfg['testmode'],"no",_('No'))?> | ||||||||||||||||||
|
|
@@ -704,6 +782,10 @@ _(Resynchronize all Primary files to Secondary)_: | |||||||||||||||||
| <input type="submit" name="#apply" value="_(Apply)_" id='Apply'> | ||||||||||||||||||
| <input type="button" id="DONE" value="_(Done)_" onclick="done()"> | ||||||||||||||||||
| <input type="button" id="Defaults" value="_(Defaults)_" onclick="resetDefaults(); location.reload()"> | ||||||||||||||||||
| <?if ($showMoverButton):?> | ||||||||||||||||||
| <input type="button" name="StartTuneMover" value="_(Move now)_" onclick="startTuneMover(); location.reload()" title="Run Mover Tuning ..."<?if ($moverRunning):?> disabled<?endif;?>> | ||||||||||||||||||
| <?if ($moverRunning):?><span>_(Mover is running)_</span><?endif;?> | ||||||||||||||||||
| <?endif;?> | ||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
| </span> | ||||||||||||||||||
|
|
||||||||||||||||||
| </form> | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,4 +48,5 @@ sparsnessv="1" | |
| filetypesv="" | ||
| omoverthresh="" | ||
| cron="" | ||
| moverTuneCron="" | ||
| forceParity="no" | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,9 @@ | ||||||||||||||||||||||||||||||||||
| #!/usr/bin/php | ||||||||||||||||||||||||||||||||||
| <?PHP | ||||||||||||||||||||||||||||||||||
| exec("/usr/local/sbin/mover.old start >> /var/log/syslog &", $output, $retval); | ||||||||||||||||||||||||||||||||||
| $vars = @parse_ini_file("/var/local/emhttp/var.ini"); | ||||||||||||||||||||||||||||||||||
| if (version_compare($vars['version'], '7.2.1', '<')) { | ||||||||||||||||||||||||||||||||||
| exec("/usr/local/sbin/mover.old start >> /var/log/syslog &", $output, $retval); | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| exec("/usr/local/sbin/mover start >> /var/log/syslog &", $output, $retval); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+3
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add null check for parse_ini_file failure. If $vars = @parse_ini_file("/var/local/emhttp/var.ini");
+if (!$vars || !isset($vars['version'])) {
+ exec("/usr/local/sbin/mover.old start >> /var/log/syslog &", $output, $retval);
+ exit;
+}
if (version_compare($vars['version'], '7.2.1', '<')) {
exec("/usr/local/sbin/mover.old start >> /var/log/syslog &", $output, $retval);
} else {
exec("/usr/local/sbin/mover start >> /var/log/syslog &", $output, $retval);
}📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Check: Codacy Static Code Analysis[warning] 3-3: source/ca.mover.tuning/usr/local/emhttp/plugins/ca.mover.tuning/moveNow.php#L3 [warning] 4-4: source/ca.mover.tuning/usr/local/emhttp/plugins/ca.mover.tuning/moveNow.php#L4 [failure] 7-7: source/ca.mover.tuning/usr/local/emhttp/plugins/ca.mover.tuning/moveNow.php#L7 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| ?> | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add validation for empty version string.
The version extraction from
/etc/unraid-versioncould potentially result in an emptyUNRAID_VERSIONif the file format is unexpected or missing. This would causeversion_geto produce incorrect results and the subsequent conditional logic to fail silently.Consider adding validation:
🤖 Prompt for AI Agents