Files
webgui/plugins/dynamix/NewPerms.page
2020-10-31 17:05:45 -04:00

116 lines
4.2 KiB
Plaintext

Menu="UNRAID-OS"
Title="New Permissions"
Icon="icon-permissions"
Tag="folder-o"
---
<?PHP
/* Copyright 2005-2020, Lime Technology
* Copyright 2012-2020, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
?>
<?
$width = [166,300];
function data_disks($disk) {
return ( ($disk['type']=='Data' || $disk['type'] == "Cache") && $disk['status']=='DISK_OK');
}
?>
<style>
.block{display:inline-block;width:300px;margin-top:24px;margin-bottom:24px}
div.div{font-weight:bold;margin-bottom:12px}
pre.pre{margin:30px 0;padding:20px}
pre>p{margin:0;padding:0}
</style>
<script>
function setNewPerms(form) {
var dirs = '';
for (var i=1,item; item=form.includeDisk.options[i]; i++) {
if (item.selected) {
if (dirs.length) dirs += '|';
dirs += item.value;
}
}
for (var i=1,item; item=form.includeShare.options[i]; i++) {
if (item.selected) {
if (dirs.length) dirs += '|';
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,600,true);});
}
$(function() {
$('#s1').dropdownchecklist({emptyText:"_(None)_", width:<?=$width[0]?>, firstItemChecksAll:true, explicitClose:"..._(close)_"});
$('#s2').dropdownchecklist({emptyText:"_(None)_", width:<?=$width[0]?>, firstItemChecksAll:true, explicitClose:"..._(close)_"});
<?if ($var['fsState']!="Started"):?>
$('#s1').dropdownchecklist('disable');
$('#s2').dropdownchecklist('disable');
<?endif;?>
});
</script>
:newperms_1_plug:
This is a mandatory one-time action to be taken after upgrading from a pre-5.0 Unraid server release to Unraid v5 or a later release.
Select **ALL DISKS** when performing this one-time action.
This utility is also useful for restoring default ownership/permissions on files and
directories when transitioning back from Active Directory to non-Active Directory integration.
The utility starts a background process that goes to each of your data disks and cache disks and selected user shares
and changes file and directory ownership to *nobody/users* (i.e., uid/gid to 99/100), and sets permissions
as follows:
:end
<pre class="pre">
:newperms_2_plug:
For directories:
drwxrwxrwx
For read/write files:
-rw-rw-rw-
For readonly files:
-r--r--r--
:end
</pre>
:newperms_3_plug:
Clicking **Start** will open another window and start the background process.
Closing the window before completion will terminate the background process - so don't do that. This process can take a long time if you have many files.
Note that this tool may negatively affect any docker containers if you allow your appdata share to be included.
:end
<form method="POST" action="/update.htm" target="progressFrame">
<span class="block"><div class="div">_(Disks)_</div>
<select id="s1" name="includeDisk" size="1" multiple="multiple" style="display:none">
<option value=''>_(All)_</option>
<?foreach (array_filter($disks,'data_disks') as $disk):?>
<?=mk_option(1,"/mnt/{$disk['name']}",_(my_disk($disk['name'])),3)?>
<?endforeach;?>
</select>
</span>
<span class="block"><div class="div">_(User Shares)_</div>
<select id="s2" name="includeShare" size="1" multiple="multiple" style="display:none">
<option value=''>_(All)_</option>
<?uksort($shares,'strnatcasecmp');?>
<?foreach ($shares as $share):?>
<?=mk_option(1,"/mnt/user/{$share['name']}",$share['name'])?>
<?endforeach;?>
</select>
</span>
<?if ($var['fsState']=="Started"):?>
<div><input type="button" value="_(Start)_" onclick="setNewPerms(this.form)"><input type="button" value="_(Done)_" class="lock" onclick="done()"></div>
<?else:?>
<div><input type="button" value="_(Start)_" disabled><input type="button" value="_(Done)_" class="lock" onclick="done()">_(Array must be **Started** to change permissions)_.</div>
<?endif;?>
</form>