forked from xtr4nge/FruityWifi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-modules.py
executable file
·78 lines (61 loc) · 2.43 KB
/
install-modules.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python
# Copyright (C) 2013-2014 xtr4nge [_AT_] gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys, getopt
import urllib2
from xml.dom.minidom import parse
from xml.dom import Node
from pprint import pprint
import subprocess, os
# get FruityWifi version
cmd = "cat /usr/share/FruityWifi/www/config/config.php |grep version"
f = os.popen(cmd)
output = f.read()
version = str(output).replace('\n','').replace('$version="v','').replace('";','')
url = urllib2.urlopen("https://raw.githubusercontent.com/xtr4nge/FruityWifi/master/modules-FruityWifi.xml")
dom = parse( url )
for modules in dom.getElementsByTagName('module'):
info = {
'name': '',
'version': '',
'author': '',
'description': '',
'url': '',
'required': '',
}
for item in modules.childNodes:
if item.nodeName == "name":
info['name'] = item.childNodes[0].nodeValue
if item.nodeName == "version":
info['version'] = item.childNodes[0].nodeValue
if item.nodeName == "author":
info['author'] = item.childNodes[0].nodeValue
if item.nodeName == "description":
info['description'] = item.childNodes[0].nodeValue
if item.nodeName == "url":
info['url'] = item.childNodes[0].nodeValue
if item.nodeName == "required":
info['required'] = item.childNodes[0].nodeValue
# Install module
if (float(version)) >= float(info['required']):
print info['name'] + " v" + info['version']
cmd_install = "git clone https://github.com/xtr4nge/module_"+info['name']+".git /usr/share/FruityWifi/www/modules/"+info['name']
print cmd_install
os.system(cmd_install)
cmd_install = "cd /usr/share/FruityWifi/www/modules/"+info['name']+"/includes/; chmod 755 install.sh; ./install.sh;"
os.system(cmd_install)
print
else:
print "Module " + info['name'] + " requires FruityWifi >= v" + info['required']