Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions bin/kano-memory-monitor
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python

# kano-memory-monitor
#
# Copyright (C) 2015-2016 Kano Computing Ltd.
# License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2
#
# DBus daemon which handles memory reservation and monitoring

# The deamon uses a system bus under the bus name 'me.kano.memory'


import sys
import traceback
import dbus.exceptions
from dbus.mainloop.glib import DBusGMainLoop

from gi.repository import GObject

from kano.logging import logger

from kano_monitor.service import MonitorService, BUS_NAME



def main():
GObject.threads_init()
DBusGMainLoop(set_as_default=True)

try:
# reserving the bus name, other instances of $0 will fail
bus_name = dbus.service.BusName(BUS_NAME, bus=dbus.SystemBus(), do_not_queue=True)

# available services, add more here
service = MonitorService(bus_name)

except dbus.exceptions.NameExistsException as e:
logger.warn('Could not reserve the SystemBus name, most likely another instance'
' of kano-boards-daemon already exists. - [{}]'.format(e))
return 1

except Exception as e:
logger.error('Unexpected error when starting the services.\n{}'
.format(traceback.format_exc()))
return 2

GObject.MainLoop().run()


if __name__ == '__main__':
sys.exit(main())
17 changes: 17 additions & 0 deletions config/dbus/me.kano.monitor.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">

<busconfig>

<policy context="default">

<!-- Allow kano-boards-daemon to reserve the bus name -->
<allow own="me.kano.monitor"/>

<!-- Allow clients to call methods on interfaces on this bus name -->
<allow send_destination="me.kano.monitor"/>

</policy>

</busconfig>
3 changes: 3 additions & 0 deletions config/sudoers.d/kano-desktop_conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ Cmnd_Alias KILL_DESKTOP_WIDGETS = /usr/bin/pkill kano-settings, \

# allow user to switch to virtual console terminals
%sudo ALL=(root) NOPASSWD: /bin/chvt

# kano-memory-monitor is run as root to allow pid tracking
%sudo ALL=(root) NOPASSWD: /usr/bin/kano-memory-monitor
5 changes: 5 additions & 0 deletions debian/install
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ config/gtk-2.0 etc/skel/.config/
config/dconf etc/skel/.config/
config/console usr/share/kano-desktop/config

config/dbus/me.kano.monitor.conf /etc/dbus-1/system.d/

config/sudoers.d/* usr/share/kano-desktop/config/sudoers.d

config/systemd/kano.conf /lib/systemd/system/user@.service.d
Expand All @@ -35,6 +37,7 @@ bin/open-me etc/skel/.Rabbithole
bin/use-the-force usr/bin
bin/make-adventures usr/bin
bin/kano-keyboard-hotkeys usr/bin
bin/kano-memory-monitor usr/bin

scripts/* usr/share/kano-desktop/scripts

Expand All @@ -44,3 +47,5 @@ kano-mount-trigger/kano-mount-trigger /usr/bin/
kano-mount-trigger/95-kano-mount-trigger.rules /lib/udev/rules.d/

systemd/* /usr/lib/systemd/user/

kano_monitor /usr/lib/python2.7/dist-packages/
5 changes: 5 additions & 0 deletions kano_monitor/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# __init__.py
#
# Copyright (C) 2015-2016 Kano Computing Ltd.
# License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2
#
Loading