mirror of
https://github.com/unraid/webgui.git
synced 2026-05-05 01:09:25 -05:00
New Perms: Support multi-cache
This commit is contained in:
@@ -17,9 +17,8 @@ Tag="folder-o"
|
||||
?>
|
||||
<?
|
||||
$width = [166,300];
|
||||
|
||||
function data_disks($disk) {
|
||||
return ($disk['type']=='Data' && $disk['status']=='DISK_OK');
|
||||
return ( ($disk['type']=='Data' || $disk['type'] == "Cache") && $disk['status']=='DISK_OK');
|
||||
}
|
||||
?>
|
||||
<style>
|
||||
@@ -44,7 +43,7 @@ function setNewPerms(form) {
|
||||
dirs += item.value;
|
||||
}
|
||||
}
|
||||
if (dirs) swal({title:"_(Proceed)_?",text:"_(This will update folder & file permissions)_",type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(Cancel)_"},function(){openBox("/webGui/scripts/newperms&arg1="+dirs,"_(New Permissions)_",490,430,true);});
|
||||
if (dirs) swal({title:"_(Proceed)_?",text:"_(This will update folder & file permissions)_",type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(Cancel)_"},function(){openBox("/webGui/scripts/newperms&arg1="+dirs,"_(New Permissions)_",490,600,true);});
|
||||
}
|
||||
$(function() {
|
||||
$('#s1').dropdownchecklist({emptyText:"_(None)_", width:<?=$width[0]?>, firstItemChecksAll:true, explicitClose:"..._(close)_"});
|
||||
@@ -93,9 +92,6 @@ Note that this tool may negatively affect any docker containers if you allow you
|
||||
<span class="block"><div class="div">_(Disks)_</div>
|
||||
<select id="s1" name="includeDisk" size="1" multiple="multiple" style="display:none">
|
||||
<option value=''>_(All)_</option>
|
||||
<?if (isset($disks['cache'])):?>
|
||||
<option value='/mnt/cache'>_(Cache)_</option>
|
||||
<?endif;?>
|
||||
<?foreach (array_filter($disks,'data_disks') as $disk):?>
|
||||
<?=mk_option(1,"/mnt/{$disk['name']}",_(my_disk($disk['name'])),3)?>
|
||||
<?endforeach;?>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#!/usr/bin/php
|
||||
<?
|
||||
# Usage: newperms [dir] [owner] [group]
|
||||
# Recursively changes the ownership and permissions of the directory and all files/subdirs
|
||||
# within the directory.
|
||||
@@ -16,35 +16,47 @@
|
||||
# go+u Copy the user permissions to group and other
|
||||
# ugo+X Set the 'x' bit for directories in user, group, and other
|
||||
|
||||
function process {
|
||||
list="$1"
|
||||
[[ $# -ge 2 ]] && owner=$2 || owner=nobody
|
||||
[[ $# -ge 3 ]] && group=$3 || group=users
|
||||
ifs=$IFS; IFS='|'
|
||||
for dir in $list; do
|
||||
echo "$dir"
|
||||
if [[ -d $dir ]]; then
|
||||
echo processing "$dir"
|
||||
echo ... chmod -R u-x,go-rwx,go+u,ugo+X "$dir"
|
||||
chmod -R u-x,go-rwx,go+u,ugo+X "$dir"
|
||||
echo ... chown -R $owner:$group "$dir"
|
||||
chown -R $owner:$group "$dir"
|
||||
echo ... sync
|
||||
sync
|
||||
fi
|
||||
done
|
||||
IFS=$ifs
|
||||
function process($path) {
|
||||
global $argv;
|
||||
|
||||
$owner = $argv[2] ?: "nobody";
|
||||
$group = $argv[3] ?: "users";
|
||||
|
||||
$dirs = array_diff(scandir($path),array(".",".."));
|
||||
foreach ($dirs as $dir) {
|
||||
echo "\n";
|
||||
if ( is_dir("$path/$dir") ) {
|
||||
echo "processing ".escapeshellarg("$path/$dir")."\n";
|
||||
echo "... chmod -R u-x,go-rwx,go+u,ugo+X ".escapeshellarg("$path/$dir")."\n";
|
||||
passthru("chmod -R u-x,go-rwx,go+u,ugo+X ".escapeshellarg("$path/$dir"));
|
||||
echo "... chown -R $owner:$group ".escapeshellarg("$path/$dir")."\n";
|
||||
passthru("chown -R $owner:$group ".escapeshellarg("$path/$dir"));
|
||||
echo "... sync\n";
|
||||
passthru("sync");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if [[ -n $1 ]]; then
|
||||
process "$@"
|
||||
else
|
||||
process /mnt/cache
|
||||
for disk in /mnt/disk[0-9]*; do
|
||||
process $disk
|
||||
done
|
||||
fi
|
||||
$startTime = time();
|
||||
|
||||
echo
|
||||
secs=$SECONDS
|
||||
printf "completed, elapsed time: %.2d:%.2d:%.2d\n" $(($secs/3600)) $(($secs%3600/60)) $(($secs%60))
|
||||
if ($argv[1]) {
|
||||
$paths=explode("|",$argv[1]);
|
||||
foreach ($paths as $path)
|
||||
process($path);
|
||||
} else {
|
||||
$disks = parse_ini_file("/var/local/emhttp/disks.ini",true);
|
||||
foreach ($disks as $disk => $prop) {
|
||||
if ( is_dir("/mnt/$disk") && $prop['status'] !== "DISK_NP_DSBL" && $prop['status'] !== "DISK_NP") {
|
||||
process("/mnt/$disk");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$seconds = time() - $startTime;
|
||||
$hours = floor($seconds / 3600);
|
||||
$mins = floor($seconds / 60 % 60);
|
||||
$secs = floor($seconds % 60);
|
||||
|
||||
echo "completed, elapsed time: ".sprintf('%02d:%02d:%02d', $hours, $mins, $secs)."\n";
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user