if ($_POST['action'] == 'add') { $jobID = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'sourcecfg', 'action' => 'add', 'args' => $_POST['mount'])); } if ($_POST['action'] == 'edit') { $jobID = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'sourcecfg', 'action' => 'edit', 'args' => $_POST['mount'])); } if ($_POST['action'] == 'delete') { $jobID = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'sourcecfg', 'action' => 'delete', 'args' => $_POST['mount'])); } if ($_POST['action'] == 'reset') { $jobID = wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'sourcecfgman', 'action' => 'reset')); } } } waitSyWrk($redis, $jobID); $source = netMounts($redis, 'read'); if ($source !== true) { foreach ($source as $mp) { if (wrk_checkStrSysfile('/proc/mounts', '/mnt/MPD/NAS/' . $mp['name'])) { $mp['status'] = 1; } else { $mp['status'] = 0; } $mounts[] = $mp; } } $template->mounts = $mounts; $usbmounts = $redis->hGetAll('usbmounts'); foreach ($usbmounts as $usbmount) { $template->usbmounts[] = json_decode($usbmount); }
function netMounts($redis, $action, $data = null) { // mountpoint input format // $data = array( 'name' => '', 'type' => '', 'address' => '', 'remotedir' => '', 'username' => '', 'password' => '', 'charset' => '', 'rsize' => '', 'wsize' => '', 'options' => '', 'error' => '' ); switch ($action) { case 'list': $mp = $redis->Keys('mount_*'); runelog('keys list: ', $mp); break; case 'read': if (isset($data)) { $mp = $redis->hGetAll($data); } else { $mp = array(); $mounts = netMounts($redis, 'list'); foreach ($mounts as $mount) { $mp[] = netMounts($redis, 'read', $mount); } } break; case 'write': $redis->hSet('mount_' . $data['name'], 'name', $data['name']) || ($mp = 0); $redis->hSet('mount_' . $data['name'], 'type', $data['type']) || ($mp = 0); $redis->hSet('mount_' . $data['name'], 'address', $data['address']) || ($mp = 0); $redis->hSet('mount_' . $data['name'], 'remotedir', $data['remotedir']) || ($mp = 0); $redis->hSet('mount_' . $data['name'], 'username', $data['username']) || ($mp = 0); $redis->hSet('mount_' . $data['name'], 'password', $data['password']) || ($mp = 0); $redis->hSet('mount_' . $data['name'], 'charset', $data['charset']) || ($mp = 0); $redis->hSet('mount_' . $data['name'], 'rsize', $data['rsize']) || ($mp = 0); $redis->hSet('mount_' . $data['name'], 'wsize', $data['wsize']) || ($mp = 0); $redis->hSet('mount_' . $data['name'], 'options', $data['options']) || ($mp = 0); $redis->hSet('mount_' . $data['name'], 'error', $data['error']) || ($mp = 0); if (!isset($mp)) { $mp = 1; } else { $redis->Del('mount_' . $data['name']); } break; case 'delete': if (isset($data)) { $mp = $redis->Del('mount_' . $data['name']); } else { $mp = sysCmd('redis-cli KEYS "mount_*" | xargs redis-cli DEL'); } break; } return $mp; }