2018-04-05 14:12:03 -07:00
|
|
|
import cmd from './cmd'
|
|
|
|
import tc from '@uci/try-catch'
|
|
|
|
|
2019-01-01 20:13:14 -08:00
|
|
|
async function disconnect(iface) {
|
2018-04-05 14:12:03 -07:00
|
|
|
if (!iface) return { error: 'can not disconnect - no interface given' }
|
|
|
|
let cmdStr = `nmcli device disconnect ${iface}`
|
|
|
|
let ret = await tc(cmd)(cmdStr)
|
2019-01-01 20:13:14 -08:00
|
|
|
if (ret.err)
|
|
|
|
return { error: 'disconnect failed', cmd: ret.err.cmd, message: ret.err }
|
|
|
|
return { disconnect: 'success', iface: iface }
|
2018-04-05 14:12:03 -07:00
|
|
|
} // end disconnect
|
2019-01-01 20:13:14 -08:00
|
|
|
|
|
|
|
export default disconnect
|