forked from ajenti/ajenti
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathajenti-pkg
More file actions
executable file
·63 lines (54 loc) · 1.72 KB
/
ajenti-pkg
File metadata and controls
executable file
·63 lines (54 loc) · 1.72 KB
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
#!/usr/bin/env python
from ajenti import plugmgr
import os
import sys
import logging
from ajenti.config import Config
def main():
if os.path.isfile('/etc/ajenti/ajenti.conf'):
config_file = '/etc/ajenti/ajenti.conf'
elif os.path.isfile(os.path.join(sys.path[0], 'ajenti.conf')):
config_file = os.path.join(sys.path[0], 'ajenti.conf')
print 'Loading plugins'
config = Config()
config.load(config_file)
plugmgr.load_plugins(config.get('ajenti', 'plugins'), None)
mgr = plugmgr.PluginManager(config)
if sys.argv[1] == 'list':
for i in mgr.installed:
print_one(i)
if sys.argv[1] == 'avail':
for i in mgr.available:
print_one(i)
if sys.argv[1] == 'remove':
for pkg in sys.argv[2:]:
print 'Removing', pkg
mgr.remove(pkg)
print 'Done'
if sys.argv[1] == 'get':
for pkg in sys.argv[2:]:
print 'Downloading', pkg
mgr.install(pkg)
print 'Done'
if sys.argv[1] == 'update':
print 'Downloading plugin list'
mgr.update_list()
print 'Done'
if sys.argv[1] == 'upgrade':
print 'Downloading plugin list'
mgr.update_list()
print 'Upgrading Ajenti plugins'
for pkg in mgr.available:
for p in mgr.installed:
if pkg.id == p.id and pkg.version != p.version:
print 'Downloading', pkg.id
mgr.install(pkg.id)
print 'Done'
def print_one(i):
st = 'i ' if i.installed else ' .'
if i.problem:
st = ' X'
print ' %s\t%s\t%s' % (st, i.version, i.id)
if i.problem:
print '\t\t\t' + i.problem
main()