mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
262dc06b99
ejsnet command line utility (perhaps to be moved to utils later...)
rafal
(This used to be commit 43f9d9ba71
)
47 lines
812 B
JavaScript
Executable File
47 lines
812 B
JavaScript
Executable File
#!/usr/bin/env smbscript
|
|
|
|
libinclude("base.js");
|
|
|
|
/* note: these require specifying a proper path in "js include" parameter */
|
|
libinclude("ejsnet/netusr.js");
|
|
libinclude("ejsnet/nethost.js");
|
|
|
|
function PrintNetHelp()
|
|
{
|
|
println("Usage: ejsnet.js <cmd> [options]");
|
|
}
|
|
|
|
/* here we start */
|
|
|
|
var options = GetOptions(ARGV,
|
|
"POPT_AUTOHELP",
|
|
"POPT_COMMON_SAMBA",
|
|
"POPT_COMMON_CREDENTIALS");
|
|
if (options == undefined) {
|
|
PrintNetHelp();
|
|
return -1;
|
|
}
|
|
|
|
if (options.ARGV.length < 1) {
|
|
PrintNetHelp();
|
|
return -1;
|
|
}
|
|
|
|
/* use command line creds if available */
|
|
var creds = options.get_credentials();
|
|
var ctx = NetContext(creds);
|
|
|
|
var cmd = options.ARGV[0];
|
|
if (cmd == "user") {
|
|
UserManager(ctx, options);
|
|
|
|
} else if (cmd == "host") {
|
|
HostManager(ctx, options);
|
|
|
|
} else {
|
|
PrintNetHelp();
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|