Revert "remove unused credentials ejs module."
[kai/samba-autobuild/.git] / testprogs / ejs / ejsnet.js
1 #!/usr/bin/env smbscript
2
3 libinclude("base.js");
4
5 /* note: these require specifying a proper path in "js include" parameter */
6 libinclude("ejsnet/netusr.js");
7 libinclude("ejsnet/nethost.js");
8
9 function PrintNetHelp()
10 {
11         println("Usage: ejsnet.js <cmd> [options]");
12 }
13
14 /* here we start */
15
16 var options = GetOptions(ARGV, 
17                 "POPT_AUTOHELP",
18                 "POPT_COMMON_SAMBA",
19                 "POPT_COMMON_CREDENTIALS");
20 if (options == undefined) {
21         PrintNetHelp();
22         return -1;
23 }
24
25 if (options.ARGV.length < 1) {
26         PrintNetHelp();
27         return -1;
28 }
29
30 /* use command line creds if available */
31 var creds = options.get_credentials();
32 var ctx = NetContext(creds);
33
34 var cmd = options.ARGV[0];
35 if (cmd == "user") {
36         UserManager(ctx, options);
37
38 } else if (cmd == "host") {
39         HostManager(ctx, options);
40
41 } else {
42         PrintNetHelp();
43         return -1;
44 }
45
46 return 0;