$cmd = urldecode($_POST['command']);
     set_config($serial, "command_bg.{$part}", urldecode($_POST['background']));
     echo json_encode(array('result' => set_config($serial, "command.{$part}", $cmd)));
     break;
 case 'remove_config':
     $serial = urldecode($_POST['serial']);
     echo json_encode(array('result' => remove_config_disk($serial)));
     break;
 case 'toggle_share':
     $info = json_decode(html_entity_decode($_POST['info']), true);
     $status = urldecode($_POST['status']);
     $result = toggle_share($info['serial'], $info['part'], $status);
     echo json_encode(array('result' => $result));
     if ($result && strlen($info['target'])) {
         add_smb_share($info['mountpoint'], $info['label']);
         add_nfs_share($info['mountpoint']);
     } else {
         rm_smb_share($info['mountpoint'], $info['label']);
         rm_nfs_share($info['mountpoint']);
     }
     break;
     /*  DISK  */
 /*  DISK  */
 case 'mount':
     $device = urldecode($_POST['device']);
     exec("plugins/{$plugin}/scripts/rc.unassigned mount '{$device}' >/dev/null 2>&1 &");
     break;
 case 'umount':
     $device = urldecode($_POST['device']);
     exec("plugins/{$plugin}/scripts/rc.unassigned umount '{$device}' >/dev/null 2>&1 &");
     break;
Пример #2
0
function reload_shares()
{
    // Disk mounts
    foreach (get_unasigned_disks() as $name => $disk) {
        foreach ($disk['partitions'] as $p) {
            if (is_mounted(realpath($p), true)) {
                $info = get_partition_info($p);
                $attrs = isset($_ENV['DEVTYPE']) ? get_udev_info($device, $_ENV, $reload) : get_udev_info($device, NULL, $reload);
                if (config_shared($info['serial'], $info['part'], strpos($attrs['DEVPATH'], "usb"))) {
                    unassigned_log("Reloading shared dir '{$info[target]}'.");
                    unassigned_log("Removing old config...");
                    rm_smb_share($info['target'], $info['label']);
                    rm_nfs_share($info['target']);
                    unassigned_log("Adding new config...");
                    add_smb_share($info['mountpoint'], $info['label']);
                    add_nfs_share($info['mountpoint']);
                }
            }
        }
    }
    // SMB Mounts
    foreach (get_samba_mounts() as $name => $info) {
        if (is_mounted($info['device'])) {
            unassigned_log("Reloading shared dir '{$info[mountpoint]}'.");
            unassigned_log("Removing old config...");
            rm_smb_share($info['mountpoint'], $info['device']);
            add_smb_share($info['mountpoint'], $info['device']);
        }
    }
    // Iso File Mounts
    foreach (get_iso_mounts() as $name => $info) {
        if (is_mounted($info['device'])) {
            unassigned_log("Reloading shared dir '{$info[mountpoint]}'.");
            unassigned_log("Removing old config...");
            rm_smb_share($info['mountpoint'], $info['device']);
            rm_nfs_share($info['mountpoint']);
            add_smb_share($info['mountpoint'], $info['device']);
            add_nfs_share($info['mountpoint']);
        }
    }
}