summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2013-02-11 10:16:25 +0000
committerPaul Eggleton <paul.eggleton@linux.intel.com>2013-02-18 09:28:26 +0000
commitdbb905c9786eb4686ebc85d8e5aad1f481591448 (patch)
tree0e307d630757b37955d278bf9c60db865c994b31
parentcc00595f68cb8f9530b9f2a723e757e18192ab9f (diff)
downloadmeta-openembedded-dbb905c9786eb4686ebc85d8e5aad1f481591448.tar.gz
ajenti: add new recipe
Add new recipe for the Ajenti web administration interface. This was developed and tested with assistance from Kevin Strasser <kevin.strasser@linux.intel.com> Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
-rw-r--r--meta-webserver/recipes-webadmin/ajenti/ajenti/0001-setup.py-remove-extra-data-files.patch33
-rw-r--r--meta-webserver/recipes-webadmin/ajenti/ajenti/0002-plugins-hddstat-fix-disk-usage-check-to-work-with-bu.patch29
-rw-r--r--meta-webserver/recipes-webadmin/ajenti/ajenti/0003-plugins-sysload-fix-to-work-with-busybox.patch47
-rw-r--r--meta-webserver/recipes-webadmin/ajenti/ajenti/0005-plugins-power-fix-shutdown.patch31
-rw-r--r--meta-webserver/recipes-webadmin/ajenti/ajenti/0006-plugins-services-add-basic-sysvinit-implementation.patch119
-rw-r--r--meta-webserver/recipes-webadmin/ajenti/ajenti/0007-plugins-services-replace-s_upstart-with-s_init-in-MO.patch23
-rw-r--r--meta-webserver/recipes-webadmin/ajenti/ajenti/distributor-logo-openembedded.pngbin0 -> 2165 bytes
-rw-r--r--meta-webserver/recipes-webadmin/ajenti/ajenti/distro-detection-openembedded.patch42
-rw-r--r--meta-webserver/recipes-webadmin/ajenti/ajenti_git.bb80
9 files changed, 404 insertions, 0 deletions
diff --git a/meta-webserver/recipes-webadmin/ajenti/ajenti/0001-setup.py-remove-extra-data-files.patch b/meta-webserver/recipes-webadmin/ajenti/ajenti/0001-setup.py-remove-extra-data-files.patch
new file mode 100644
index 000000000..11d7a9292
--- /dev/null
+++ b/meta-webserver/recipes-webadmin/ajenti/ajenti/0001-setup.py-remove-extra-data-files.patch
@@ -0,0 +1,33 @@
1From 37bf4c471f23140e00fe87dde6f7c3cf38933c22 Mon Sep 17 00:00:00 2001
2From: Paul Eggleton <paul.eggleton@linux.intel.com>
3Date: Mon, 12 Mar 2012 02:01:48 +0000
4Subject: [PATCH] setup.py: remove extra data files
5
6Don't install files using setup.py, since this fails due to absolute
7paths and we can easily install these within the recipe instead.
8
9Upstream-Status: Inappropriate [config]
10
11Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
12---
13 setup.py | 6 ------
14 1 files changed, 0 insertions(+), 6 deletions(-)
15
16diff --git a/setup.py b/setup.py
17index 8daea4c..11e3acb 100755
18--- a/setup.py
19+++ b/setup.py
20@@ -18,10 +18,4 @@ setup(
21 packages = find_packages(),
22 package_data={'': ['files/*.*', 'files/*/*.*', 'files/*/*/*.*', 'templates/*.*', 'widgets/*.*', 'layout/*.*']},
23 scripts=['ajenti-panel', 'ajenti-pkg'],
24- data_files=[
25- ('/etc/ajenti', ['packaging/files/ajenti.conf']),
26- ('/etc/ajenti/users', ['packaging/files/admin.conf']),
27- ('/etc/init.d', ['packaging/files/ajenti']),
28- ('/var/lib/ajenti/plugins', ['packaging/files/.placeholder']),
29- ],
30 )
31--
321.7.5.4
33
diff --git a/meta-webserver/recipes-webadmin/ajenti/ajenti/0002-plugins-hddstat-fix-disk-usage-check-to-work-with-bu.patch b/meta-webserver/recipes-webadmin/ajenti/ajenti/0002-plugins-hddstat-fix-disk-usage-check-to-work-with-bu.patch
new file mode 100644
index 000000000..48c255dbb
--- /dev/null
+++ b/meta-webserver/recipes-webadmin/ajenti/ajenti/0002-plugins-hddstat-fix-disk-usage-check-to-work-with-bu.patch
@@ -0,0 +1,29 @@
1From cde811cfffba48c148b60fb1083fe8fd409b8b24 Mon Sep 17 00:00:00 2001
2From: Paul Eggleton <paul.eggleton@linux.intel.com>
3Date: Tue, 13 Mar 2012 01:52:34 +0000
4Subject: [PATCH 1/2] plugins/hddstat: fix disk usage check to work with
5 busybox
6
7busybox df does not have --total, so fake it using awk.
8
9Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
10---
11 plugins/hddstat/usage.py | 2 +-
12 1 files changed, 1 insertions(+), 1 deletions(-)
13
14diff --git a/plugins/hddstat/usage.py b/plugins/hddstat/usage.py
15index 3c84181..cf5f037 100644
16--- a/plugins/hddstat/usage.py
17+++ b/plugins/hddstat/usage.py
18@@ -7,7 +7,7 @@ class DiskUsageMeter(LinearMeter):
19 transform = 'percent'
20
21 def get_usage(self):
22- u = int(shell('df --total | grep total').split().pop().strip('%'))
23+ u = int(round(float(shell("df -P | awk 'NR > 1 {total+=$3+$4 ; used+=$3} END { print used/total*100}'").strip())))
24 return u
25
26 def get_value(self):
27--
281.7.4.4
29
diff --git a/meta-webserver/recipes-webadmin/ajenti/ajenti/0003-plugins-sysload-fix-to-work-with-busybox.patch b/meta-webserver/recipes-webadmin/ajenti/ajenti/0003-plugins-sysload-fix-to-work-with-busybox.patch
new file mode 100644
index 000000000..1efec9b92
--- /dev/null
+++ b/meta-webserver/recipes-webadmin/ajenti/ajenti/0003-plugins-sysload-fix-to-work-with-busybox.patch
@@ -0,0 +1,47 @@
1From 552c46fb22fe336175c42612c33ceb0828ddd6aa Mon Sep 17 00:00:00 2001
2From: Paul Eggleton <paul.eggleton@linux.intel.com>
3Date: Tue, 13 Mar 2012 01:54:09 +0000
4Subject: [PATCH 2/2] plugins/sysload: fix to work with busybox
5
6The busybox free command does not support -b, so specify -k (which is
7also ignored, but will help if real "free" is being used) and multiply
8kb values by 1024.
9
10Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
11---
12 plugins/sysload/ss_linux.py | 18 +++++++++++-------
13 1 files changed, 11 insertions(+), 7 deletions(-)
14
15diff --git a/plugins/sysload/ss_linux.py b/plugins/sysload/ss_linux.py
16index cab7708..be60c53 100644
17--- a/plugins/sysload/ss_linux.py
18+++ b/plugins/sysload/ss_linux.py
19@@ -11,14 +11,18 @@ class LinuxSysStat(Plugin):
20 return open('/proc/loadavg', 'r').read().split()[0:3]
21
22 def get_ram(self):
23- s = shell('free -b | grep Mem').split()[1:]
24- t = int(s[0])
25- u = int(s[1])
26- b = int(s[4])
27- c = int(s[5])
28+ # busybox free doesn't support -b
29+ s = shell('free -k | grep Mem').split()[1:]
30+ t = int(s[0]) * 1024
31+ u = int(s[1]) * 1024
32+ b = int(s[4]) * 1024
33+ if len(s) > 5:
34+ c = int(s[5]) * 1024
35+ else:
36+ c = 0
37 u -= c + b;
38 return (u, t)
39
40 def get_swap(self):
41- s = shell('free -b | grep Swap').split()[1:]
42- return (int(s[1]), int(s[0]))
43+ s = shell('free -k | grep Swap').split()[1:]
44+ return (int(s[1]) * 1024, int(s[0]) * 1024)
45--
461.7.4.4
47
diff --git a/meta-webserver/recipes-webadmin/ajenti/ajenti/0005-plugins-power-fix-shutdown.patch b/meta-webserver/recipes-webadmin/ajenti/ajenti/0005-plugins-power-fix-shutdown.patch
new file mode 100644
index 000000000..2934385b2
--- /dev/null
+++ b/meta-webserver/recipes-webadmin/ajenti/ajenti/0005-plugins-power-fix-shutdown.patch
@@ -0,0 +1,31 @@
1From acd997cf610f8e9b0dbea00d2f1184d256d1b85b Mon Sep 17 00:00:00 2001
2From: Paul Eggleton <paul.eggleton@linux.intel.com>
3Date: Sat, 17 Mar 2012 23:50:48 +0000
4Subject: [PATCH] plugins/power: fix shutdown
5
6Fix shutdown to use the -h option together with -P (which is required
7for sysvinit shutdown.)
8
9Upstream-Status: Pending
10
11Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
12---
13 plugins/power/main.py | 2 +-
14 1 files changed, 1 insertions(+), 1 deletions(-)
15
16diff --git a/plugins/power/main.py b/plugins/power/main.py
17index 0ab6337..069bde7 100755
18--- a/plugins/power/main.py
19+++ b/plugins/power/main.py
20@@ -57,7 +57,7 @@ class PowerPlugin(CategoryPlugin):
21 @event('button/click')
22 def on_aclick(self, event, params, vars=None):
23 if params[0] == 'shutdown':
24- shell('shutdown -P now')
25+ shell('shutdown -h -P now')
26 if params[0] == 'reboot':
27 shell('reboot')
28
29--
301.7.5.4
31
diff --git a/meta-webserver/recipes-webadmin/ajenti/ajenti/0006-plugins-services-add-basic-sysvinit-implementation.patch b/meta-webserver/recipes-webadmin/ajenti/ajenti/0006-plugins-services-add-basic-sysvinit-implementation.patch
new file mode 100644
index 000000000..651018e5a
--- /dev/null
+++ b/meta-webserver/recipes-webadmin/ajenti/ajenti/0006-plugins-services-add-basic-sysvinit-implementation.patch
@@ -0,0 +1,119 @@
1From 57f949a7ab34812d8384bf41c05c3b25bdade92b Mon Sep 17 00:00:00 2001
2From: Paul Eggleton <paul.eggleton@linux.intel.com>
3Date: Sun, 18 Mar 2012 14:26:34 +0000
4Subject: [PATCH] plugins/services: add basic sysvinit implementation
5
6This allows operation on systems that don't have the "service" command.
7The PID finding is a little hacky but mostly works. Note that this uses
8psutil to detect whether the service is really running rather than just
9assuming that it is if the pid file exists.
10
11Note: you need to remove s_upstart.py before this will work.
12
13Upstream-Status: Pending
14
15Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
16---
17 plugins/services/s_init.py | 90 ++++++++++++++++++++++++++++++++++++++++++++
18 1 files changed, 90 insertions(+), 0 deletions(-)
19 create mode 100755 plugins/services/s_init.py
20
21diff --git a/plugins/services/s_init.py b/plugins/services/s_init.py
22new file mode 100755
23index 0000000..6f38b0a
24--- /dev/null
25+++ b/plugins/services/s_init.py
26@@ -0,0 +1,90 @@
27+# Basic sysvinit service backend implementation for Ajenti Services plugin
28+#
29+# Copyright (C) 2012 Intel Corporation
30+# Author: Paul Eggleton <paul.eggleton@linux.intel.com>
31+#
32+
33+import os
34+import psutil
35+
36+from ajenti.com import *
37+from ajenti.utils import *
38+from ajenti import apis
39+from ajenti.api import *
40+
41+def find_service_pid(service):
42+ svcfile = os.path.join('/etc/init.d', service)
43+ pidfile = ''
44+ try:
45+ svcf = open(svcfile)
46+ except:
47+ return None
48+ while 1:
49+ line = svcf.readline()
50+ if not line:
51+ break
52+ if line.startswith('PID='):
53+ pidfile = line.split('=')[1].strip("'\n\r \"")
54+ break
55+ svcf.close()
56+ if not pidfile:
57+ pf = '/var/run/%s.pid' % service
58+ if os.path.exists(pf):
59+ pidfile = pf
60+ else:
61+ pf = '/var/run/%sd.pid' % service
62+ if os.path.exists(pf):
63+ pidfile = pf
64+ if pidfile:
65+ pidf = open(pidfile)
66+ pid = pidf.readline()
67+ pidf.close
68+ if pid:
69+ pid = pid.strip()
70+ pid = int(pid)
71+ try:
72+ p = psutil.Process(pid)
73+ except:
74+ pid = None
75+ return pid
76+ return None
77+
78+
79+class UpstartServiceManager(Plugin):
80+ implements(apis.services.IServiceManager)
81+ platform = ['debian']
82+
83+ def list_all(self):
84+ r = []
85+
86+ blacklist = 'functions mountall.sh save-rtc.sh umountnfs.sh populate-volatile.sh rcS bootlogd urandom halt sendsigs single bootmisc.sh sysfs.sh mountnfs.sh busybox-udhcpc devpts.sh banner.sh modutils.sh checkroot.sh networking umountfs udev rc hostname.sh fbsetup stop-bootlogd rmnologin.sh reboot hwclock.sh read-only-rootfs-hook.sh functions.initscripts syslog.busybox'.split()
87+
88+ for f in os.listdir('/etc/init.d'):
89+ if not f in blacklist:
90+ svc = apis.services.Service()
91+ svc.name = f
92+ pid = find_service_pid(f)
93+ if pid:
94+ svc.status = 'running'
95+ else:
96+ svc.status = 'stopped'
97+ r.append(svc)
98+
99+ return sorted(r, key=lambda s: s.name)
100+
101+ def get_status(self, name):
102+ pid = find_service_pid(name)
103+ if pid:
104+ return 'running'
105+ else:
106+ return 'stopped'
107+
108+ def start(self, name):
109+ shell('/etc/init.d/%s start' % name)
110+
111+ def stop(self, name):
112+ shell('/etc/init.d/%s stop' % name)
113+
114+ def restart(self, name):
115+ shell('/etc/init.d/%s restart' % name)
116+
117--
1181.7.5.4
119
diff --git a/meta-webserver/recipes-webadmin/ajenti/ajenti/0007-plugins-services-replace-s_upstart-with-s_init-in-MO.patch b/meta-webserver/recipes-webadmin/ajenti/ajenti/0007-plugins-services-replace-s_upstart-with-s_init-in-MO.patch
new file mode 100644
index 000000000..7623e3f6e
--- /dev/null
+++ b/meta-webserver/recipes-webadmin/ajenti/ajenti/0007-plugins-services-replace-s_upstart-with-s_init-in-MO.patch
@@ -0,0 +1,23 @@
1From 75b5109ceb4874c967daf6c1e8434e6093b1df79 Mon Sep 17 00:00:00 2001
2From: Kevin Strasser <kevin.strasser@linux.intel.com>
3Date: Mon, 29 Oct 2012 01:44:10 -0700
4Subject: [PATCH] plugins/services: replace s_upstart with s_init in MODULES
5
6Signed-off-by: Kevin Strasser <kevin.strasser@linux.intel.com>
7---
8 plugins/services/__init__.py | 2 +-
9 1 file changed, 1 insertion(+), 1 deletion(-)
10
11diff --git a/plugins/services/__init__.py b/plugins/services/__init__.py
12index 6cf58e5..ced3300 100755
13--- a/plugins/services/__init__.py
14+++ b/plugins/services/__init__.py
15@@ -1,4 +1,4 @@
16-MODULES = ['api', 'main', 'meter', 'widget', 's_upstart', 's_arch', 's_bsd', 's_centos', 's_gentoo']
17+MODULES = ['api', 'main', 'meter', 'widget', 's_init', 's_arch', 's_bsd', 's_centos', 's_gentoo']
18
19 DEPS = [
20 (['centos', 'fedora'],
21--
221.7.9.5
23
diff --git a/meta-webserver/recipes-webadmin/ajenti/ajenti/distributor-logo-openembedded.png b/meta-webserver/recipes-webadmin/ajenti/ajenti/distributor-logo-openembedded.png
new file mode 100644
index 000000000..0aad9df90
--- /dev/null
+++ b/meta-webserver/recipes-webadmin/ajenti/ajenti/distributor-logo-openembedded.png
Binary files differ
diff --git a/meta-webserver/recipes-webadmin/ajenti/ajenti/distro-detection-openembedded.patch b/meta-webserver/recipes-webadmin/ajenti/ajenti/distro-detection-openembedded.patch
new file mode 100644
index 000000000..9ef9bac74
--- /dev/null
+++ b/meta-webserver/recipes-webadmin/ajenti/ajenti/distro-detection-openembedded.patch
@@ -0,0 +1,42 @@
1From 5b3864f5ff76915887774fa78961616b6e7c1649 Mon Sep 17 00:00:00 2001
2From: Paul Eggleton <paul.eggleton@linux.intel.com>
3Date: Thu, 15 Mar 2012 03:25:36 +0000
4Subject: [PATCH] Hardcode distro detection
5
6Use "openembedded" as the distro identification string if none is able
7to be detected.
8
9Upstream-Status: Inappropriate [config]
10
11Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
12---
13 ajenti/utils/utils.py | 6 +++++-
14 1 files changed, 5 insertions(+), 1 deletions(-)
15
16diff --git a/ajenti/utils/utils.py b/ajenti/utils/utils.py
17index c7e1463..98199c0 100755
18--- a/ajenti/utils/utils.py
19+++ b/ajenti/utils/utils.py
20@@ -41,6 +41,7 @@ def detect_platform(mapping=True):
21 platform_mapping = {
22 'ubuntu': 'debian',
23 'linuxmint': 'debian',
24+ 'openembedded': 'debian',
25 }
26
27 if platform.system() != 'Linux':
28@@ -57,7 +58,10 @@ def detect_platform(mapping=True):
29 try:
30 dist = shell('strings -4 /etc/issue').split()[0]
31 except:
32- dist = 'unknown'
33+ dist = ''
34+
35+ if dist == '':
36+ dist = 'openembedded'
37
38 res = dist.strip().lower()
39 if res in base_mapping:
40--
411.7.4.4
42
diff --git a/meta-webserver/recipes-webadmin/ajenti/ajenti_git.bb b/meta-webserver/recipes-webadmin/ajenti/ajenti_git.bb
new file mode 100644
index 000000000..dc1508eba
--- /dev/null
+++ b/meta-webserver/recipes-webadmin/ajenti/ajenti_git.bb
@@ -0,0 +1,80 @@
1SUMMARY = "Web-based system administration interface"
2HOMEPAGE = "http://ajenti.org"
3SECTION = "devel/python"
4LICENSE = "LGPLv3"
5LIC_FILES_CHKSUM = "file://LICENSE;md5=e6a600fd5e1d9cbde2d983680233ad02"
6
7DEPENDS += "python-pyopenssl python-lxml python-gevent python-greenlet \
8 python-psutil python-imaging"
9
10PV = "0.6.2+git${SRCPV}"
11
12SRC_URI = "git://github.com/Eugeny/ajenti.git \
13 file://0001-setup.py-remove-extra-data-files.patch \
14 file://0002-plugins-hddstat-fix-disk-usage-check-to-work-with-bu.patch \
15 file://0003-plugins-sysload-fix-to-work-with-busybox.patch \
16 file://0005-plugins-power-fix-shutdown.patch \
17 file://0006-plugins-services-add-basic-sysvinit-implementation.patch \
18 file://0007-plugins-services-replace-s_upstart-with-s_init-in-MO.patch \
19 ${DISTRO_FILES}"
20
21# Allow this to be customised easily
22DISTRO_FILES = "file://distro-detection-openembedded.patch \
23 file://distributor-logo-openembedded.png"
24
25# Corresponds to the 0.6.2 tag
26SRCREV = "c08fb4da65923aebd09116750a1f43f13b98a51a"
27
28S = "${WORKDIR}/git"
29
30inherit setuptools update-rc.d
31
32do_configure_prepend() {
33 rm ajenti/plugins/dashboard/files/distributor-logo-*.png
34 cp ${WORKDIR}/distributor-logo-*.png ajenti/plugins/dashboard/files/
35 rm plugins/services/s_upstart.py
36}
37
38do_install_append() {
39 install -d ${D}${sysconfdir}
40 install -d ${D}${sysconfdir}/ajenti
41 install -m 0644 packaging/files/ajenti.conf ${D}${sysconfdir}/ajenti/
42 install -d ${D}${sysconfdir}/ajenti/users
43 install -m 0644 packaging/files/admin.conf ${D}${sysconfdir}/ajenti/users/
44 install -d ${D}${sysconfdir}/init.d
45 install -m 0755 packaging/files/ajenti ${D}${sysconfdir}/init.d/
46 install -d ${D}${localstatedir}
47 install -d ${D}${localstatedir}/lib
48 install -d ${D}${localstatedir}/lib/ajenti
49 install -d ${D}${localstatedir}/lib/ajenti/plugins
50 install -m 0644 packaging/files/.placeholder ${D}${localstatedir}/lib/ajenti/plugins
51
52 for plugin in plugins/* ; do
53 cp -r $plugin ${D}${localstatedir}/lib/ajenti/plugins/
54 done
55}
56
57INITSCRIPT_NAME = "ajenti"
58INITSCRIPT_PARAMS = "start 99 2 3 4 5 . stop 20 0 1 6 ."
59
60python populate_packages_prepend() {
61 plugindir = d.expand('${localstatedir}/lib/ajenti/plugins')
62 do_split_packages(d, plugindir, '(^[^.]*$)', 'ajenti-plugin-%s', 'Ajenti plugin for %s', allow_dirs=True, prepend=False)
63}
64
65PACKAGES_DYNAMIC = "ajenti-plugin-*"
66FILES_${PN} += "${sysconfdir}/ajenti.conf \
67 ${sysconfdir}/ajenti \
68 ${sysconfdir}/init.d \
69 ${localstatedir}/lib/ajenti/plugins/.placeholder"
70RDEPENDS_${PN} += "python-re python-json python-logging python-subprocess \
71 python-threading python-setuptools python-netclient \
72 python-netserver python-shell python-syslog \
73 python-pyopenssl python-lxml python-gevent python-greenlet"
74RDEPENDS_${PN}-plugin-taskmgr += "python-psutil"
75RDEPENDS_${PN}-plugin-services += "python-psutil"
76RDEPENDS_${PN}-plugin-logs += "python-compression"
77RDEPENDS_${PN}-plugin-terminal += "python-compression python-codecs python-math \
78 python-terminal python-imaging"
79RDEPENDS_${PN}-plugin-fm += "python-unixadmin"
80