mirror of
https://github.com/unraid/webgui.git
synced 2026-01-06 01:29:54 -06:00
Merge branch 'master' of https://github.com/bergware/webgui
This commit is contained in:
@@ -187,7 +187,7 @@ function decrypt_data($data) {
|
||||
|
||||
/* Ensure the decrypted data is UTF-8 encoded. */
|
||||
if (!mb_check_encoding($decrypted, 'UTF-8')) {
|
||||
unassigned_log("Warning: Data is not UTF-8 encoded");
|
||||
outgoingproxy_log("Warning: Data is not UTF-8 encoded");
|
||||
$decrypted = "";
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ function write(...$messages){
|
||||
foreach ($messages as $message) publish('diagnostics', $message);
|
||||
}
|
||||
|
||||
// Modify run function to include error logging
|
||||
function run($cmd, &$save=null, $timeout=30) {
|
||||
// output command for display
|
||||
write($cmd);
|
||||
@@ -109,19 +110,16 @@ function maskIP($file) {
|
||||
|
||||
// anonymize public IPv4 addresses
|
||||
$rfc1918 = "(127|10|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)((\.[0-9]{1,3}){2,3}([/\" .]|$))";
|
||||
run("sed -ri 's/([\"\[ ]){$rfc1918}/\\1@@@\\2\\3/g; s/([\"\[ ][0-9]{1,3}\.)([0-9]{1,3}\.){2}([0-9]{1,3})([/\" .]|$)/\\1XXX.XXX.\\3\\4/g; s/@@@//g' ".escapeshellarg($file)." 2>/dev/null");
|
||||
|
||||
// anonymize full IPv6 addresses
|
||||
$file_escaped = escapeshellarg($file);
|
||||
run("sed -ri 's/([\"\[ ]){$rfc1918}/\\1@@@\\2\\3/g; s/([\"\[ ][0-9]{1,3}\.)([0-9]{1,3}\.){2}([0-9]{1,3})([/\" .]|$)/\\1XXX.XXX.\\3\\4/g; s/@@@//g' ".escapeshellarg($file));
|
||||
|
||||
// Anonymize IPv6 addresses without brackets
|
||||
run("sed -ri 's/(([0-9a-f]{1,4}:){4})(([0-9a-f]{1,4}:){3}|:)([0-9a-f]{1,4})([ .:/]|$)/\\1XXXX:XXXX:XXXX:\\5\\6/g' $file_escaped 2>/dev/null");
|
||||
run("sed -ri 's/(([0-9a-f]{1,4}:){4})(([0-9a-f]{1,4}:){3}|:)([0-9a-f]{1,4})([ .:/]|$)/\\1XXXX:XXXX:XXXX:\\5\\6/g' ".escapeshellarg($file));
|
||||
|
||||
// Anonymize IPv6 addresses with brackets
|
||||
run("sed -ri 's/(\[([0-9a-f]{1,4}:){4})(([0-9a-f]{1,4}:){3}|:)([0-9a-f]{1,4})(\])([ .:/]|$)/\\1XXXX:XXXX:XXXX:\\5\\6/g' $file_escaped 2>/dev/null");
|
||||
run("sed -ri 's/(\[([0-9a-f]{1,4}:){4})(([0-9a-f]{1,4}:){3}|:)([0-9a-f]{1,4})(\])([ .:/]|$)/\\1XXXX:XXXX:XXXX:\\5\\6/g' ".escapeshellarg($file));
|
||||
|
||||
// Handle any remaining edge cases, e.g., addresses with subnet masks
|
||||
run("sed -ri 's/(([0-9a-f]{1,4}:){4})(([0-9a-f]{1,4}:){3}|:)([0-9a-f]{1,4})(\/[0-9]{1,3})([ .:/]|$)/\\1XXXX:XXXX:XXXX:\\5\\7/g' $file_escaped 2>/dev/null");
|
||||
run("sed -ri 's/(([0-9a-f]{1,4}:){4})(([0-9a-f]{1,4}:){3}|:)([0-9a-f]{1,4})(\/[0-9]{1,3})([ .:/]|$)/\\1XXXX:XXXX:XXXX:\\5\\7/g' ".escapeshellarg($file));
|
||||
}
|
||||
|
||||
function download_url($url, $path="", $bg=false, $timeout=15) {
|
||||
@@ -321,16 +319,16 @@ function anonymize_syslog($file) {
|
||||
foreach ($titles as $mover) {
|
||||
if (!$mover) continue;
|
||||
$title = "/{$mover[0]}..".substr($mover,-1)."/...";
|
||||
run("sed -i 's/".str_replace("/","\/",$mover)."/".str_replace("/","\/",$title)."/g' ".escapeshellarg("$log.txt")." 2>/dev/null");
|
||||
//run("sed -ri 's|(file: [.>cr].*)[ /]$mover/.*$|\\1 file: $title|' ".escapeshellarg("$log.txt")." 2>/dev/null");
|
||||
run("sed -i 's/".str_replace("/","\/",$mover)."/".str_replace("/","\/",$title)."/g' ".escapeshellarg("$log.txt"));
|
||||
//run("sed -ri 's|(file: [.>cr].*)[ /]$mover/.*$|\\1 file: $title|' ".escapeshellarg("$log.txt"));
|
||||
}
|
||||
run("grep -n ' cache_dirs: -' ".escapeshellarg("$log.txt")." 2>/dev/null|cut -d: -f1", $rows);
|
||||
for ($i = 0; $i < count($rows); $i += 2) for ($row = $rows[$i]+1; $row < $rows[$i+1]; $row++) run("sed -ri '$row s|(cache_dirs: \S).*(\S)|\\1..\\2|' ".escapeshellarg("$log.txt")." 2>/dev/null");
|
||||
for ($i = 0; $i < count($rows); $i += 2) for ($row = $rows[$i]+1; $row < $rows[$i+1]; $row++) run("sed -ri '$row s|(cache_dirs: \S).*(\S)|\\1..\\2|' ".escapeshellarg("$log.txt"));
|
||||
}
|
||||
// replace consecutive repeated lines in syslog
|
||||
run("awk -i inplace '{if(s!=substr(\$0,17)){if(x>0)print\"### [PREVIOUS LINE REPEATED \"x\" TIMES] ###\\r\";print;x=0}else{x++}s=substr(\$0,17)}END{if(x>0)print\"### [PREVIOUS LINE REPEATED \"x\" TIMES] ###\\r\"}' ".escapeshellarg("$log.txt"));
|
||||
run("awk -b -i inplace '{if(s!=substr($0,17)){if(x>0)print\"### [PREVIOUS LINE REPEATED \"x\" TIMES] ###\r\";print;x=0}else{x++}s=substr($0,17)}END{if(x>0)print\"### [PREVIOUS LINE REPEATED \"x\" TIMES] ###\r\"}' ".escapeshellarg("$log.txt"));
|
||||
// remove SHA256 hashes
|
||||
run("sed -ri 's/(SHA256:).+[^\s\b]/SHA256:***REMOVED***/gm' $log.txt");
|
||||
run("sed -ri 's/(SHA256:).+[^\s\b]/SHA256:***REMOVED***/gm' ".escapeshellarg("$log.txt"));
|
||||
// truncate syslog if too big
|
||||
if (basename($file)=='syslog' && filesize($file)>=$max) run("tail -n 200 ".escapeshellarg("$log.txt")." >".escapeshellarg("$log.last200.txt"));
|
||||
run("truncate -s '<$max' ".escapeshellarg("$log.txt"));
|
||||
@@ -435,7 +433,7 @@ file_put_contents("/$diag/system/loads.txt",$cpuload.implode("\r\n",$loadTxt));
|
||||
run("lscpu 2>/dev/null|todos >".escapeshellarg("/$diag/system/lscpu.txt"));
|
||||
run("lsscsi -vgl 2>/dev/null|todos >".escapeshellarg("/$diag/system/lsscsi.txt"));
|
||||
run("lspci -knn 2>/dev/null|todos >".escapeshellarg("/$diag/system/lspci.txt"));
|
||||
run("lspci -vv 2>/dev/null| awk '/ASPM/{print $0}' RS=|grep -P '(^[a-z0-9:.]+|ASPM |Disabled;|Enabled;)'|todos >".escapeshellarg("/$diag/system/aspm-status.txt"));
|
||||
run("lspci -vv 2>/dev/null| awk -b '/ASPM/{print $0}' RS=|grep -P '(^[a-z0-9:.]+|ASPM |Disabled;|Enabled;)'|todos >".escapeshellarg("/$diag/system/aspm-status.txt"));
|
||||
run("lsusb 2>/dev/null|todos >".escapeshellarg("/$diag/system/lsusb.txt"));
|
||||
run("free -mth 2>/dev/null|todos >".escapeshellarg("/$diag/system/memory.txt"));
|
||||
run("lsof -Pni 2>/dev/null|todos >".escapeshellarg("/$diag/system/lsof.txt"));
|
||||
@@ -471,8 +469,8 @@ foreach ($folders as $folder) {
|
||||
}
|
||||
|
||||
// copy configuration files (suppress errors)
|
||||
run("cp /boot/config/*.{cfg,conf,dat} ".escapeshellarg("/$diag/config")." 2>/dev/null");
|
||||
run("cp /boot/config/go ".escapeshellarg("/$diag/config/go.txt")." 2>/dev/null");
|
||||
run("cp /boot/config/*.{cfg,conf,dat} ".escapeshellarg("/$diag/config"));
|
||||
run("cp /boot/config/go ".escapeshellarg("/$diag/config/go.txt"));
|
||||
|
||||
// anonymize go file
|
||||
if (!$all) {
|
||||
@@ -480,18 +478,18 @@ if (!$all) {
|
||||
}
|
||||
// anonymize configuration files
|
||||
if (!$all) {
|
||||
run("sed -ri 's/^((disk|flash)(Read|Write)List.*=\")[^\"]+/\\1.../' ".escapeshellarg("/$diag/config/*.cfg")." 2>/dev/null");
|
||||
run("find ".escapeshellarg("/$diag/config")." -name '*.cfg' -exec sed -ri 's/^((disk|flash)(Read|Write)List.*=\")[^\"]+/\\1.../' {} \\;");
|
||||
// anonymize IP addresses
|
||||
maskIP("/$diag/config/network.cfg");
|
||||
// anonymize wireless credentials
|
||||
if (file_exists("/$diag/config/wireless.cfg")) {
|
||||
run("sed -ri 's/^((USERNAME|PASSWORD)=\")[^\"]+/\\1.../' ".escapeshellarg("/$diag/config/wireless.cfg")." 2>/dev/null");
|
||||
run("sed -ri 's/^((USERNAME|PASSWORD)=\")[^\"]+/\\1.../' ".escapeshellarg("/$diag/config/wireless.cfg"));
|
||||
}
|
||||
}
|
||||
// include listening interfaces
|
||||
run("$docroot/webGui/scripts/show_interfaces ip|tr ',' '\n' >".escapeshellarg("/$diag/config/listen.txt"));
|
||||
run("$docroot/webGui/scripts/error_interfaces|sed 's/<i.*i>//' >>".escapeshellarg("/$diag/config/listen.txt"));
|
||||
if (!$all) maskIP("/$diag/config/listen.txt");
|
||||
maskIP("/$diag/config/listen.txt");
|
||||
|
||||
// copy share information (anonymize if applicable)
|
||||
$files = glob("/boot/config/shares/*.cfg");
|
||||
@@ -501,7 +499,7 @@ foreach ($files as $file) {
|
||||
$share = basename($file,'.cfg');
|
||||
if (!in_array($share,$showshares)) $dest = anonymize($dest,2);
|
||||
@copy($file, $dest);
|
||||
if (!$all) run("sed -ri 's/^(share(Comment|ReadList|WriteList)=\")[^\"]+/\\1.../' ".escapeshellarg($dest)." 2>/dev/null");
|
||||
if (!$all) run("sed -ri 's/^(share(Comment|ReadList|WriteList)=\")[^\"]+/\\1.../' ".escapeshellarg($dest));
|
||||
$home = shareDisks($share);
|
||||
$home = $home ? "# Share exists on $home\r\n" : "# Share does not exist\r\n";
|
||||
$shareDisk[] = str_pad(basename($dest,'.cfg'),34).str_pad(exec("grep -m1 'shareUseCache' ".escapeshellarg($file)),24).$home;
|
||||
@@ -657,13 +655,13 @@ if ($qemu) {
|
||||
}
|
||||
|
||||
// copy VM XML config files
|
||||
run("cp /etc/libvirt/qemu/*.xml ".escapeshellarg("/$diag/xml")." 2>/dev/null");
|
||||
run("cp /etc/libvirt/qemu/*.xml ".escapeshellarg("/$diag/xml"));
|
||||
|
||||
// anonymize MAC OSK info
|
||||
$all_xml = glob("/$diag/xml/*.xml");
|
||||
foreach ($all_xml as $xml) {
|
||||
run("sed -ri 's/(,osk=).+/\\1.../' ".escapeshellarg("$xml")." 2>/dev/null");
|
||||
run("sed -ri 's/(passwd=).+/\\1.../' ".escapeshellarg("$xml")." 2>/dev/null");
|
||||
run("sed -ri 's/(,osk=).+/\\1.../' ".escapeshellarg("$xml"));
|
||||
run("sed -ri 's/(passwd=).+/\\1.../' ".escapeshellarg("$xml"));
|
||||
}
|
||||
|
||||
// copy syslog information (anonymize if applicable)
|
||||
@@ -679,7 +677,7 @@ $dhcplog = "/var/log/dhcplog";
|
||||
if (file_exists($dhcplog)) {
|
||||
$log = "/$diag/logs/dhcplog.txt";
|
||||
run("todos <$dhcplog >".escapeshellarg($log));
|
||||
if (!$all) maskIP($log);
|
||||
maskIP($log);
|
||||
}
|
||||
|
||||
// copy phplog
|
||||
@@ -730,8 +728,8 @@ newline("/$diag/system/sshd.txt");
|
||||
// copy servers.conf
|
||||
copy("/etc/nginx/conf.d/servers.conf", "/$diag/system/servers.conf.txt");
|
||||
maskIP("/$diag/system/servers.conf.txt");
|
||||
run("sed -Ei 's/[01234567890abcdef]+\.((my)?unraid\.net)/hash.\\1/gm;t' ".escapeshellarg("/$diag/system/servers.conf.txt")." 2>/dev/null");
|
||||
run("sed -Ei 's/\.[^\.]*\.ts\.net/\.magicdns\.ts\.net/gm' ".escapeshellarg("/$diag/system/servers.conf.txt")." 2>/dev/null");
|
||||
run("sed -Ei 's/[01234567890abcdef]+\.((my)?unraid\.net)/hash.\\1/gm;t' ".escapeshellarg("/$diag/system/servers.conf.txt"));
|
||||
run("sed -Ei 's/\.[^\.]*\.ts\.net/\.magicdns\.ts\.net/gm' ".escapeshellarg("/$diag/system/servers.conf.txt"));
|
||||
newline("/$diag/system/servers.conf.txt");
|
||||
|
||||
// show installed patches
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
### END INIT INFO
|
||||
|
||||
# get correct location of binaries from configure
|
||||
sbindir=${exec_prefix}/sbin
|
||||
sbindir=/usr/sbin
|
||||
CGCONFIGPARSER_BIN=$sbindir/cgconfigparser
|
||||
CONFIG_FILE=/etc/cgconfig.conf
|
||||
CONFIG_DIR=/etc/cgconfig.d
|
||||
@@ -32,6 +32,25 @@ servicename=cgconfig
|
||||
|
||||
|
||||
lockfile=/run/lock/subsys/$servicename
|
||||
#
|
||||
# Source LSB routines
|
||||
#
|
||||
SYSLIBFILE=/lib/lsb/init-functions
|
||||
OLDSYSLIBFILE=/etc/init.d/functions
|
||||
if [[ -x $SYSLIBFILE ]] ; then
|
||||
# shellcheck disable=SC1090
|
||||
source $SYSLIBFILE
|
||||
elif [[ -x $OLDSYSLIBFILE ]] ; then
|
||||
# shellcheck disable=SC1090
|
||||
source $OLDSYSLIBFILE
|
||||
log_warning_msg() ( warning "$@" ; printf "\n" 1>&2 ; )
|
||||
log_failure_msg() ( failure "$@" ; printf "\n" 1>&2 ; )
|
||||
log_success_msg() ( success "$@" ; printf "\n" 1>&2 ; )
|
||||
else
|
||||
log_warning_msg() ( printf "warning:%s\n" "$@" 1>&2 ;)
|
||||
log_failure_msg() ( printf "failure:%s\n" "$@" 1>&2 ;)
|
||||
log_success_msg() ( printf "success:%s\n" "$@" 1>&2 ;)
|
||||
fi
|
||||
|
||||
# read the config
|
||||
CREATE_DEFAULT=yes
|
||||
@@ -50,8 +69,8 @@ create_default_groups() {
|
||||
read -r user ctrl defaultcgroup <<< \
|
||||
"$(grep -m1 '^\*[[:space:]]\+' /etc/cgrules.conf)"
|
||||
if [[ ( -n "$defaultcgroup" ) && ( "$defaultcgroup" = "*" ) ]]; then
|
||||
echo "/etc/cgrules.conf incorrect"
|
||||
echo "Overriding it"
|
||||
log_warning_msg "/etc/cgrules.conf incorrect"
|
||||
log_warning_msg "Overriding it"
|
||||
defaultcgroup=
|
||||
fi
|
||||
fi
|
||||
@@ -94,19 +113,19 @@ create_default_groups() {
|
||||
start() {
|
||||
printf "Starting %s service: " "$servicename"
|
||||
if [[ -f "$lockfile" ]]; then
|
||||
echo "lock file already exists"
|
||||
log_warning_msg "lock file already exists"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ ! -s "$CONFIG_FILE" ]]; then
|
||||
echo $CONFIG_FILE "is not configured"
|
||||
log_failure_msg $CONFIG_FILE "is not configured"
|
||||
return 6
|
||||
fi
|
||||
|
||||
|
||||
if ! "$CGCONFIGPARSER_BIN" -l "$CONFIG_FILE" -L "$CONFIG_DIR"
|
||||
then
|
||||
echo "Failed to parse " "$CONFIG_FILE" "or" "$CONFIG_DIR"'/*'
|
||||
log_failure_msg "Failed to parse " "$CONFIG_FILE" "or" "$CONFIG_DIR"'/*'
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -115,22 +134,22 @@ start() {
|
||||
fi
|
||||
|
||||
if ! mkdir -p "$lockfiledir" ; then
|
||||
echo "Failed to mkdir $lockfiledir directory"
|
||||
log_failure_msg "Failed to mkdir $lockfiledir directory"
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
if ! touch "$lockfile" ; then
|
||||
echo "Failed to touch $lockfile"
|
||||
log_failure_msg "Failed to touch $lockfile"
|
||||
return 1
|
||||
fi
|
||||
echo "Started $servicename"
|
||||
log_success_msg "Started $servicename"
|
||||
return 0
|
||||
}
|
||||
|
||||
stop() {
|
||||
printf "Stopping %s service is not supported!: " "$servicename"
|
||||
echo "Failed to stop $servicename"
|
||||
log_failure_msg "Failed to stop $servicename"
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
# cgroups to classify processes
|
||||
### END INIT INFO
|
||||
|
||||
sbindir=${exec_prefix}/sbin
|
||||
sbindir=/usr/sbin
|
||||
CGRED_BIN=$sbindir/cgrulesengd
|
||||
|
||||
# Sanity checks
|
||||
@@ -35,7 +35,7 @@ CGRED_BIN=$sbindir/cgrulesengd
|
||||
#
|
||||
# Source LSB routines
|
||||
#
|
||||
SYSLIBFILE=/etc/rc.d/init.d/functions
|
||||
SYSLIBFILE=/lib/lsb/init-functions
|
||||
OLDSYSLIBFILE=/etc/init.d/functions
|
||||
if [[ -x $SYSLIBFILE ]] ; then
|
||||
# shellcheck disable=SC1090
|
||||
@@ -53,9 +53,9 @@ else
|
||||
fi
|
||||
|
||||
# Read in configuration options.
|
||||
if [[ -f "/etc/cgred.conf" ]] ; then
|
||||
if [[ -f "/etc/sysconfig/cgred.conf" ]] ; then
|
||||
# shellcheck disable=SC1091
|
||||
source /etc/cgred.conf
|
||||
source /etc/sysconfig/cgred.conf
|
||||
OPTIONS="$NODAEMON $LOG"
|
||||
if [[ -n "$LOG_FILE" ]]; then
|
||||
OPTIONS="$OPTIONS --logfile=$LOG_FILE"
|
||||
@@ -80,13 +80,13 @@ start()
|
||||
{
|
||||
echo -n $"Starting CGroup Rules Engine Daemon: "
|
||||
if [[ -f "$lockfile" ]]; then
|
||||
echo "$servicename is already running with PID $(cat ${pidfile})"
|
||||
log_failure_msg "$servicename is already running with PID $(cat ${pidfile})"
|
||||
return 0
|
||||
fi
|
||||
num=$(grep "cgroup" /proc/mounts | awk '$3=="cgroup"' | wc -l)
|
||||
if [[ "$num" -eq 0 ]]; then
|
||||
echo
|
||||
echo $"Cannot find cgroups, is cgconfig service running?"
|
||||
log_failure_msg $"Cannot find cgroups, is cgconfig service running?"
|
||||
return 1
|
||||
fi
|
||||
daemon --check $servicename --pidfile $pidfile $CGRED_BIN $OPTIONS
|
||||
@@ -106,7 +106,7 @@ stop()
|
||||
{
|
||||
echo -n $"Stopping CGroup Rules Engine Daemon..."
|
||||
if [[ ! -f $pidfile ]]; then
|
||||
#log_success_msg
|
||||
log_success_msg
|
||||
return 0
|
||||
fi
|
||||
killproc -p $pidfile -TERM "$processname"
|
||||
@@ -152,13 +152,13 @@ case "$1" in
|
||||
echo $"Reloading rules configuration..."
|
||||
kill -s 12 "$(cat ${pidfile})"
|
||||
RETVAL=$?
|
||||
#if [[ $RETVAL -eq 0 ]] ; then
|
||||
# log_success_msg ""
|
||||
#else
|
||||
# log_failure_msg ""
|
||||
#fi
|
||||
if [[ $RETVAL -eq 0 ]] ; then
|
||||
log_success_msg ""
|
||||
else
|
||||
log_failure_msg ""
|
||||
fi
|
||||
else
|
||||
echo "$servicename is not running."
|
||||
log_failure_msg "$servicename is not running."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
#
|
||||
# This selects your default screen font from among the ones in
|
||||
# /usr/share/kbd/consolefonts.
|
||||
|
||||
32
sbin/mover
32
sbin/mover
@@ -23,6 +23,7 @@
|
||||
# operation continues on to the next file.
|
||||
|
||||
PIDFILE="/var/run/mover.pid"
|
||||
CFGPATH="/boot/config/shares"
|
||||
DEBUGGING=""
|
||||
|
||||
move() {
|
||||
@@ -42,7 +43,7 @@ start() {
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
for SHARECFG in /boot/config/shares/*.cfg ; do
|
||||
for SHARECFG in $CFGPATH/*.cfg ; do
|
||||
SHARE=$(basename "$SHARECFG" .cfg)
|
||||
source <(fromdos < "$SHARECFG")
|
||||
|
||||
@@ -85,6 +86,13 @@ start() {
|
||||
}
|
||||
|
||||
empty() {
|
||||
DISK="$1"
|
||||
|
||||
if [ ! -d "/mnt/$DISK" ]; then
|
||||
echo "Error: disk '$DISK' not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f $PIDFILE ]; then
|
||||
if ps h $(cat $PIDFILE) | grep mover ; then
|
||||
echo "mover: already running"
|
||||
@@ -97,17 +105,22 @@ empty() {
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
# we can only empty share directories
|
||||
for SHAREPATH in /mnt/$DISK/* ; do
|
||||
if [[ -d "$SHAREPATH" ]]; then
|
||||
SHARE=$(basename "$SHAREPATH")
|
||||
if [[ -d "$SHAREPATH" && -f "$CFGPATH/$SHARE.cfg" ]]; then
|
||||
find "$SHAREPATH" -depth 2>/dev/null | /usr/libexec/unraid/move -e $DEBUGGING
|
||||
fi
|
||||
done
|
||||
|
||||
# output list of files which could not be moved
|
||||
shopt -s dotglob ; FILES=(/mnt/"$DISK"/*) ; shopt -u dotglob
|
||||
if [ ${#FILES[@]} -gt 2 ]; then
|
||||
echo "mover: not moved:"
|
||||
ls -1 --almost-all --recursive /mnt/"$DISK"
|
||||
# use 'find' in case huge number of files left in /mnt/$DISK
|
||||
count=$(find /mnt/$DISK -mindepth 1 | wc -l)
|
||||
if [ "$count" -gt 0 ]; then
|
||||
find /mnt/$DISK -mindepth 1 -depth -printf 'move: %p Not moved\n' | head -n 100
|
||||
if [ "$count" -gt 100 ]; then
|
||||
echo "[output truncated to first 100 entries]"
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f $PIDFILE
|
||||
@@ -134,9 +147,9 @@ stop() {
|
||||
echo "mover: stopped"
|
||||
}
|
||||
|
||||
# Function to display usage
|
||||
# display usage and then exit
|
||||
usage() {
|
||||
echo "Usage: $0 start [-e] <disk_name>"
|
||||
echo "Usage: $0 start [-e <disk_name>]"
|
||||
echo " $0 stop|status"
|
||||
echo " <disk_name> must match pattern 'disk[0-9]*'"
|
||||
exit 1
|
||||
@@ -164,8 +177,7 @@ start)
|
||||
usage
|
||||
else
|
||||
validate_disk "$3"
|
||||
DISK="$3"
|
||||
empty
|
||||
empty "$3"
|
||||
fi
|
||||
else
|
||||
usage
|
||||
|
||||
Reference in New Issue
Block a user