aboutsummaryrefslogtreecommitdiffstats
path: root/conf
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-10-11 17:07:16 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-01-26 21:40:08 +0100
commit1d4de11a907e41c06063a2cd5028dc4101690f50 (patch)
tree69af98bbe6512cdbcab33267574c131f85ffd597 /conf
parentbfc9c138b1a9e87f9d387e2f900c14807c9da9b9 (diff)
Prepare the Integration with systemd
This is an intermediate commit providing basic functionnalities for setting up integration of the framework with systemd. - file afm-unit.conf is a mustache template - translation of config.xml to json object - mustache (extended) application of the json to the template - post processing of the result for extracting unit files This processing is currently available as a test (and a tool) and will be integrated after more developement, test and validation. Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'conf')
-rw-r--r--conf/CMakeLists.txt5
-rw-r--r--conf/afm-unit.conf168
2 files changed, 171 insertions, 2 deletions
diff --git a/conf/CMakeLists.txt b/conf/CMakeLists.txt
index 32a0cc4..d8611e0 100644
--- a/conf/CMakeLists.txt
+++ b/conf/CMakeLists.txt
@@ -1,5 +1,5 @@
###########################################################################
-# Copyright 2015 IoT.bzh
+# Copyright 2015, 2016, 2017 IoT.bzh
#
# author: José Bollo <jose.bollo@iot.bzh>
#
@@ -30,6 +30,7 @@ if(NOT USE_SDK)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/afm-system-daemon.service DESTINATION ${UNITDIR_SYSTEM})
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/afm-user-daemon.conf DESTINATION ${SYSCONFDIR_DBUS_USER})
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/afm-user-daemon.service DESTINATION ${UNITDIR_USER})
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/afm-launch.conf DESTINATION ${afm_confdir})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/afm-launch.conf DESTINATION ${afm_confdir})
+ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/afm-unit.conf DESTINATION ${afm_confdir})
endif()
diff --git a/conf/afm-unit.conf b/conf/afm-unit.conf
new file mode 100644
index 0000000..290c3e1
--- /dev/null
+++ b/conf/afm-unit.conf
@@ -0,0 +1,168 @@
+;---------------------------------------------------------------------------------
+; File:
+;
+; afm-unit.conf
+;
+; Role:
+;
+; Configure how installation of widget produces unit files for systemd
+;
+; Processing and format:
+;
+; 1. File load
+;
+; Lines beginning with ; are firstly removed
+;
+; 2. File instanciation
+;
+; Mustache (extended) substitutions are applied using JSON
+; data deduced from config.xml file of the widget.
+;
+; 3. Extraction of units
+;
+; Extract produced units, pack it (remove empty lines and directives)
+;
+; Directives:
+;
+; All directive occopy one whole line starting with %
+;
+; - %nl
+;
+; produce an empty line at the end
+;
+; - %begin systemd-unit
+; - %end systemd-unit
+;
+; delimit the produced unit
+;
+; - %systemd-unit user
+; - %systemd-unit system
+;
+; tells the kind of unit (user/system)
+;
+; - %systemd-unit service NAME
+; - %systemd-unit socket NAME
+;
+; gives the name and type of the unit
+;
+;---------------------------------------------------------------------------------
+{{#targets}}
+%begin systemd-unit
+
+# auto generated by wgtpkg-unit for {{id}} version {{version}} target {{:#target}}
+%nl
+
+[unit]
+Description={{description}}
+X-AGL-Name={{name.content}}
+X-AGL-Name-Short={{name.short}}
+X-AGL-Id={{id}}
+X-AGL-Idaver={{idaver}}
+X-AGL-Target-Name={{:#target}}
+X-AGL-Author={{author.content}}
+X-AGL-Author-email={{author.email}}
+X-AGL-HTTP-port={{:#metadata.http-port}}
+%nl
+
+# Adds check to smack
+ConditionSecurity=smack
+%nl
+
+# Automatic bound to required bindings
+{{#required-binding}}
+BindsTo=afm-api-{{name}}
+After=afm-api-{{name}}
+{{/required-binding}}
+%nl
+
+[Service]
+SmackProcessLabel=User::App::{{id}}
+
+{{#required-permission}}
+ {{#urn:AGL:permission::platform:no-oom}} OOMScoreAdjust=-500 {{/urn:AGL:permission::platform:no-oom}}
+ {{#urn:AGL:permission::partner:real-time}} IOSchedulingClass=realtime {{/urn:AGL:permission::partner:real-time}}
+ {{^urn:AGL:permission::partner:real-time}} RestrictRealtime=on {{/urn:AGL:permission::partner:real-time}}
+ {{#urn:AGL:permission::public:display}} SupplementaryGroups=display {{/urn:AGL:permission::public:display}}
+ {{^urn:AGL:permission::public:syscall:clock}} SystemCallFilter=~@clock {{/urn:AGL:permission::public:syscall:clock}}
+ {{^urn:AGL:permission::public:internet}} RestrictAddressFamilies=AF_UNIX {{/urn:AGL:permission::public:internet}}
+{{/required-permission}}
+%nl
+
+WorkingDirectory={{&#metadata.app-data-dir}}
+
+;---------------------------------------------------------------------------------
+{{#content.type=text/html}}
+
+%systemd-unit user
+
+%systemd-unit service afm-appli-{{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}
+
+ExecStart=/usr/bin/afb-daemon --port={{:#metadata.http-port}} --random-token \
+ --rootdir={{:#metadata.install-dir}} \
+ --workdir={{&#metadata.app-data-dir}} \
+ --roothttp=htdocs \
+ {{#required-permission.urn:AGL:permission::public:applications:read}}\
+ --alias=/icons:{{:#metadata.icons-dir}} \
+ {{/required-permission.urn:AGL:permission::public:applications:read}}\
+ {{#required-binding}}\
+ {{#value=auto}}\
+ --ws-client=unix:%t/apis/ws/{{name}} \
+ {{/value=auto}}\
+ {{#value=ws}}\
+ --ws-client=unix:%t/apis/ws/{{name}} \
+ {{/value=ws}}\
+ {{#value=dbus}}\
+ --dbus-client={{name}} \
+ {{/value=dbus}}\
+ {{#value=link}}\
+ --binding=%t/apis/lib/{{name}} \
+ {{/value=link}}\
+ {{#value=cloud}}\
+ --cloud-client={{name}} \
+ {{/value=cloud}}\
+ {{/required-binding}}\
+ --exec /usr/bin/web-runtime http://localhost:@p/{{content.src}}?token=@t
+
+{{/content.type=text/html}}
+
+;---------------------------------------------------------------------------------
+{{#content.type=application/vnd.agl.service}}
+
+%systemd-unit user
+%systemd-unit service afm-api-{{:#target}}
+
+ExecStart=/usr/bin/afb-daemon \
+ --rootdir={{:#metadata.install-dir}} \
+ --workdir={{&#metadata.install-dir}} \
+ {{^required-permission.urn:AGL:permission::partner:service:no-ws}}\
+ --ws-server=unix:%t/bindings/{{:#target}} \
+ {{/required-permission.urn:AGL:permission::partner:service:no-ws}}\
+ {{^required-permission.urn:AGL:permission::partner:service:no-dbus}}\
+ --dbus-server={{:#target}} \
+ {{/required-permission.urn:AGL:permission::partner:service:no-dbus}}\
+ --no-httpd
+
+{{^required-permission.urn:AGL:permission::partner:service:no-ws}}
+
+%end systemd-unit
+%begin systemd-unit
+
+# auto generated by wgtpkg-unit for {{id}} version {{version}} target {{:#target}}
+#
+%systemd-unit user
+%systemd-unit socket afm-api-{{:#target}}
+
+
+[socket]
+SmackLabel=*
+ListenStream=%t/bindings/{{:#target}}
+
+{{/required-permission.urn:AGL:permission::partner:service:no-ws}}
+
+{{/content.type=application/vnd.agl.service}}
+
+;---------------------------------------------------------------------------------
+%end systemd-unit
+{{/targets}}
+
+