@@ -88,8 +88,6 @@ DNSERR=no
8888
8989echo "Checking DNS..." 
9090dnscheck "mothership.unraid.net" 
91- #dnscheck "wanip4.unraid.net" 
92- #dnscheck "backup.unraid.net" 
9391
9492[[ "${DNSERR}" == "yes" && "${DNS_SERVER1}" != "8.8.8.8" ]] && echo "  Recommend navigating to Settings -> Network Settings and changing your DNS server to 8.8.8.8" 
9593# Note: DNS checks will fail if the network is not available at boot. Cannot exit the install when DNS checks fail. 
@@ -150,18 +148,6 @@ exit 0
150148    <SHA256 >&TXZ_SHA256; </SHA256 >
151149  </FILE >
152150
153-   <FILE  Run =" /bin/bash" Method =" install" 
154-     <INLINE >
155-       MAINTXZ="&source; .txz"
156-     <![CDATA[ 
157- # before proceeding with install, doubly confirm downloaded files exist. just being pedantic. 
158- FILE=${MAINTXZ} && [[ ! -f "$FILE" ]] && echo "⚠️ file missing - $FILE" && exit 1 
159- 
160- exit 0 
161- ]]> 
162-     </INLINE >
163-   </FILE >
164- 
165151  <FILE  Run =" /bin/bash" Method =" remove" 
166152    <INLINE >
167153      <![CDATA[ 
@@ -172,6 +158,10 @@ source /etc/unraid-version
172158# Undo some activation / partner setup 
173159source /usr/local/emhttp/plugins/dynamix.my.servers/scripts/activation_code_remove 
174160
161+ # Run cleanup operations 
162+ echo "Performing cleanup operations..." 
163+ /usr/bin/php /usr/local/emhttp/plugins/dynamix.my.servers/scripts/cleanup_operations.php 
164+ 
175165echo 
176166echo "⚠️ Do not close this window yet" 
177167echo 
@@ -181,144 +171,28 @@ exit 0
181171    </INLINE >
182172  </FILE >
183173
184-   <!--  disable features on uninstall --> 
185-   <!--  NOTE: this script is PHP not bash --> 
186-   <FILE  Run =" /usr/bin/php" Method =" remove" 
187-     <INLINE >
188-       <![CDATA[ 
189- <? 
190- $msini = @parse_ini_file('/boot/config/plugins/dynamix.my.servers/myservers.cfg', true); 
191- 
192- echo "\n"; 
193- echo "**********************************\n"; 
194- echo "🧹 CLEANING UP - may take a minute\n"; 
195- echo "**********************************\n"; 
196- 
197- if (file_exists("/boot/.git")) { 
198-   if (file_exists("/etc/rc.d/rc.flash_backup")) { 
199-     # stop flash backup service 
200-     echo "\nStopping flash backup service. Please wait…"; 
201-     exec("/etc/rc.d/rc.flash_backup stop &>/dev/null"); 
202-   } 
203-   if (file_exists("/usr/local/emhttp/plugins/dynamix.my.servers/include/UpdateFlashBackup.php")) { 
204-     # deactivate and delete local flash backup 
205-     echo "\nDeactivating flash backup. Please wait…"; 
206-     passthru("/usr/bin/php /usr/local/emhttp/plugins/dynamix.my.servers/include/UpdateFlashBackup.php deactivate"); 
207-   } 
208- } 
209- 
210- if (file_exists("/etc/rc.d/rc.unraid-api")) { 
211-   echo "\nStopping unraid-api. Please wait…"; 
212-   $output = shell_exec("/etc/rc.d/rc.unraid-api stop --delete 2>&1'"); 
213-   if (!$output) { 
214-     echo "Waiting for unraid-api to stop...\n"; 
215-     sleep(5); // Give it a few seconds to fully stop 
216-   } 
217-   echo "Stopped unraid-api: $output"; 
218- 
219-   # Find all PIDs referencing main.js and kill them, excluding grep process 
220-   $pids = shell_exec("ps aux | grep 'node /usr/local/unraid-api/dist/main.js' | grep -v grep | awk '{print $2}'"); 
221-   foreach(explode("\n", trim($pids)) as $pid) { 
222-     if ($pid) { 
223-       posix_kill((int)$pid, 9); 
224-     } 
225-   } 
226- } 
227- 
228- # set "Allow Remote Access" to "No" and sign out from Unraid Connect 
229- if ($msini !== false) { 
230-   if (!empty($msini['remote']['username'])) { 
231-     $var = parse_ini_file("/var/local/emhttp/var.ini"); 
232-     $keyfile = @file_get_contents($var['regFILE']); 
233-     if ($keyfile !== false) { 
234-       echo "\nSigning out of Unraid Connect\n"; 
235-       $ch = curl_init('https://keys.lime-technology.com/account/server/unregister'); 
236-       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
237-       curl_setopt($ch, CURLOPT_POST, 1); 
238-       curl_setopt($ch, CURLOPT_POSTFIELDS, ['keyfile' => @base64_encode($keyfile)]); 
239-       curl_exec($ch); 
240-       curl_close($ch); 
241-     } 
242-   } 
243- 
244-   # remove myservers.cfg 
245-   unlink('/boot/config/plugins/dynamix.my.servers/myservers.cfg'); 
246- 
247-   # reload nginx to disable Remote Access 
248-   echo "\n⚠️ Reloading Web Server. If this window stops updating for two minutes please close it.\n"; 
249-   exec("/etc/rc.d/rc.nginx reload &>/dev/null"); 
250- } 
251- exit(0); 
252- ]]> 
253-     </INLINE >
254-   </FILE >
255- 
256-   <!--  disable features when upgrading on unsupported OS versions --> 
257-   <!--  duplicated from above because the script can't distinguish between install and remove --> 
258-   <!--  NOTE: this script is PHP not bash --> 
174+   <!--  Cleanup for install on unsupported OS --> 
259175  <FILE  Run =" /usr/bin/php" Method =" install" 
260176    <INLINE >
261177      <![CDATA[ 
262- <? 
263- $ver = @parse_ini_file('/etc/unraid-version', true)['version']; 
264- $msini = @parse_ini_file('/boot/config/plugins/dynamix.my.servers/myservers.cfg', true); 
265- 
266- // exit this install block if NOT isUnsupportedVersion 
267- // must be 6.12.0 or higher (not 6.12.0-[beta|rc]) 
268- if (version_compare($ver,'6.12.0','>=')) { 
269-   exit(0); 
270- } 
178+ <?php 
179+ // Check Unraid version 
180+ $version = @parse_ini_file('/etc/unraid-version', true)['version']; 
271181
272- echo "\n"; 
273- echo "**********************************\n"; 
274- echo "🧹 CLEANING UP - may take a minute\n"; 
275- echo "**********************************\n" ;
182+ // Check if this is a supported version 
183+ // - Must be 6.12.0 or higher 
184+ // - Must not be a 6.12.0 beta/rc version 
185+ $is_stable_6_12_or_higher = version_compare($version, '6.12.0', '>=') && !preg_match('/^6\\.12\\.0-/', $version) ;
276186
277- if (file_exists("/boot/.git")) { 
278-   if (file_exists("/etc/rc.d/rc.flash_backup")) { 
279-     # stop flash backup service 
280-     echo "\nStopping flash backup service. Please wait…"; 
281-     exec("/etc/rc.d/rc.flash_backup stop &>/dev/null"); 
282-   } 
283-   if (file_exists("/usr/local/emhttp/plugins/dynamix.my.servers/include/UpdateFlashBackup.php")) { 
284-     # deactivate and delete local flash backup 
285-     echo "\nDeactivating flash backup. Please wait…"; 
286-     passthru("/usr/bin/php /usr/local/emhttp/plugins/dynamix.my.servers/include/UpdateFlashBackup.php deactivate"); 
287-   } 
187+ if ($is_stable_6_12_or_higher) { 
188+   echo "Running on supported version {$version}, skipping cleanup\n"; 
189+   exit(0); 
288190} 
289191
290- # set "Allow Remote Access" to "No" and sign out from Unraid Connect 
291- if ($msini !== false) { 
292-   # stop unraid-api 
293-   echo "\nStopping unraid-api. Please wait…"; 
294-   $output = shell_exec("/etc/rc.d/rc.unraid-api stop --delete 2>&1'"); 
295-   if (!$output) { 
296-     echo "Waiting for unraid-api to stop...\n"; 
297-     sleep(5); // Give it a few seconds to fully stop 
298-   } 
299-   echo "Stopped unraid-api: $output"; 
300- 
301-   if (!empty($msini['remote']['username'])) { 
302-     $var = parse_ini_file("/var/local/emhttp/var.ini"); 
303-     $keyfile = @file_get_contents($var['regFILE']); 
304-     if ($keyfile !== false) { 
305-       echo "\nSigning out of Unraid Connect\n"; 
306-       $ch = curl_init('https://keys.lime-technology.com/account/server/unregister'); 
307-       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
308-       curl_setopt($ch, CURLOPT_POST, 1); 
309-       curl_setopt($ch, CURLOPT_POSTFIELDS, ['keyfile' => @base64_encode($keyfile)]); 
310-       curl_exec($ch); 
311-       curl_close($ch); 
312-     } 
313-   } 
314- 
315-   # remove myservers.cfg 
316-   unlink('/boot/config/plugins/dynamix.my.servers/myservers.cfg'); 
192+ echo "Running on unsupported version {$version}, performing cleanup\n"; 
193+ echo "Running cleanup operations...\n"; 
194+ include_once("/usr/local/emhttp/plugins/dynamix.my.servers/scripts/cleanup_operations.php"); 
317195
318-   # reload nginx to disable Remote Access 
319-   echo "\n⚠️ Reloading Web Server. If this window stops updating for two minutes please close it.\n"; 
320-   exec("/etc/rc.d/rc.nginx reload &>/dev/null"); 
321- } 
322196exit(0); 
323197]]> 
324198    </INLINE >
@@ -529,6 +403,7 @@ preserveFilesDirs=(
529403preserveAction() { 
530404    local action="$1" 
531405    local path="$2" 
406+     local preventType="$3" # preventDowngrade or skip 
532407
533408    if [[ "$action" == "move" ]]; then 
534409        [[ -f "$path" ]] && mv -f "$path" "$path-" 
0 commit comments