Menu="UNRAID-OS"
Title="New Permissions"
Tag="hand-paper-o"
---
<?PHP
/* Copyright 2005-2017, Lime Technology
 * Copyright 2012-2017, 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 = strstr('gray,azure',$display['theme']) ? [166,305]:[131,300];

function data_disks($disk) {
  return ($disk['type']=='Data' && $disk['status']=='DISK_OK');
}
?>
<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',showCancelButton:true},function(){openBox('/webGui/scripts/newperms&arg1='+dirs,'New Permissions',490,430,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>
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:
~~~
For directories:
  drwxrwxrwx

For read/write files:
  -rw-rw-rw-

For readonly files:
  -r--r--r--
~~~
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.

<form method="POST" action="/update.htm" target="progressFrame">
<span style="display:inline-block;margin-top:8px">
<span style="display:block;margin-bottom:4px;font-weight:bold">Disks</span>
<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']))?>
<?endforeach;?>
</select>
</span>
<span style="display:inline-block">
<span style="display:block;margin-bottom:4px;font-weight:bold">User Shares</span>
<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>
<br><br>
<?if ($var['fsState']=="Started"):?>
<input type="button" value="Start" onclick="setNewPerms(this.form)"><input type="button" value=" Done " onclick="done()">
<?else:?>
<input type="button" value="Start" disabled><input type="button" value=" Done " onclick="done()"> Array must be <span class="strong big">Started</span> to change permissions.
<?endif;?>
</form>
