forked from usmannasir/cyberpanel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CloudLinuxResellers.py
executable file
·64 lines (51 loc) · 1.67 KB
/
CloudLinuxResellers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/local/CyberCP/bin/python
import sys
import os.path
import django
sys.path.append('/usr/local/CyberCP')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
try:
django.setup()
except:
pass
from loginSystem.models import Administrator, ACL
import argparse
import json
from CLScript.CLMain import CLMain
class CloudLinuxResellers(CLMain):
def __init__(self, id, name):
CLMain.__init__(self)
self.id = id
self.name = name
def listAll(self, owner=None):
import pwd
users = []
acl = ACL.objects.get(name='reseller')
from plogical.vhost import vhost
for items in Administrator.objects.filter(acl=acl):
if self.name != None:
if self.name != items.userName:
continue
try:
uid = pwd.getpwnam(items.userName).pw_uid
except:
vhost.addUser(items.userName, '/home/%s' % (items.userName))
uid = pwd.getpwnam(items.userName).pw_uid
user = {'name': items.userName,
"locale_code": "EN_us",
"email": items.email,
"id": uid
}
users.append(user)
final = {'data': users, 'metadata': self.initialMeta}
print(json.dumps(final))
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='CyberPanel CloudLinux Manager')
parser.add_argument('--id', help='Owner')
parser.add_argument('-n', '--name', help='Owner')
args = parser.parse_args()
pi = CloudLinuxResellers(args.id, args.name)
try:
pi.listAll()
except:
pi.listAll()