aboutsummaryrefslogtreecommitdiffstats
path: root/conf
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2018-07-19 11:29:36 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2018-07-19 15:38:29 +0200
commit8c7132a146aa744f167ea2fc45dcd8d53018ecc0 (patch)
tree62bb28dc2831417d2406a30b4c8b38bd133b45bb /conf
parentd8d819bcde18c8b4b5dfbdf610a6fc5e04fa54bf (diff)
Creates systemd service for APIs
Before this change, APIs were only provided as binder's exported websockets. This forbade ability to use symbolic links. Allowing links is interesting for having platform sockets and for linked api (not using socket). The API afm-main is a platform API. It must run at system level and must be available for all user clients. To achieve it, we use a link. Bug-AGL: SPEC-1592 Change-Id: I8753f83373755eb7fc2d2cc50251b8f738b61b03 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'conf')
-rw-r--r--conf/system/CMakeLists.txt2
-rw-r--r--conf/system/afm-api-afm-main@.service.in13
-rw-r--r--conf/unit/afm-unit-debug.conf.in48
-rw-r--r--conf/unit/afm-unit.conf.in48
-rw-r--r--conf/unit/generate-unit-conf/afm-unit4
-rw-r--r--conf/unit/generate-unit-conf/provided.inc62
-rw-r--r--conf/unit/generate-unit-conf/service.inc8
7 files changed, 142 insertions, 43 deletions
diff --git a/conf/system/CMakeLists.txt b/conf/system/CMakeLists.txt
index c36128f..26fc562 100644
--- a/conf/system/CMakeLists.txt
+++ b/conf/system/CMakeLists.txt
@@ -20,6 +20,7 @@ cmake_minimum_required(VERSION 2.8)
configure_file(afm-system-daemon.service.in afm-system-daemon.service)
configure_file(afm-system-daemon.socket.in afm-system-daemon.socket)
+configure_file(afm-api-afm-main@.service.in afm-api-afm-main@.service)
if(NOT USE_SDK)
set(SYSCONFDIR_DBUS_SYSTEM ${CMAKE_INSTALL_SYSCONFDIR}/dbus-1/system.d CACHE STRING "Path to dbus system configuration files")
@@ -30,6 +31,7 @@ if(NOT USE_SDK)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/afm-user-session.pamd DESTINATION ${SYSCONFDIR_PAMD} RENAME afm-user-session)
install(
FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/afm-api-afm-main@.service
${CMAKE_CURRENT_BINARY_DIR}/afm-system-daemon.service
${CMAKE_CURRENT_BINARY_DIR}/afm-system-daemon.socket
${CMAKE_CURRENT_SOURCE_DIR}/afm-system-setup.service
diff --git a/conf/system/afm-api-afm-main@.service.in b/conf/system/afm-api-afm-main@.service.in
new file mode 100644
index 0000000..f5b2519
--- /dev/null
+++ b/conf/system/afm-api-afm-main@.service.in
@@ -0,0 +1,13 @@
+[Unit]
+Description=Provides api afm-main for user %i
+X-AFM-API-TYPE=ws
+
+Requires=afm-user-setup@%i.service
+After=afm-user-setup@%i.service
+Requires=afm-system-daemon.socket
+After=afm-system-daemon.socket
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/bin/ln -s @afm_platform_rundir@/apis/ws/afm-main /run/user/%i/apis/ws/afm-main
diff --git a/conf/unit/afm-unit-debug.conf.in b/conf/unit/afm-unit-debug.conf.in
index 05881fa..55af22d 100644
--- a/conf/unit/afm-unit-debug.conf.in
+++ b/conf/unit/afm-unit-debug.conf.in
@@ -113,14 +113,14 @@ ConditionSecurity=smack
# Automatic bound to required api
{{#required-api}}
{{#value=auto|ws}}
-BindsTo=afm-api-ws-{{name}}@%i.socket
-After=afm-api-ws-{{name}}@%i.socket
+BindsTo=afm-api-{{name}}@%i.service
+After=afm-api-{{name}}@%i.service
{{/value=auto|ws}}
{{/required-api}}
{{#provided-api}}
{{#value=ws|auto}}
-Requires=afm-api-ws-{{name}}@%i.socket
-After=afm-api-ws-{{name}}@%i.socket
+Requires=afm-api-{{name}}@%i.service
+After=afm-api-{{name}}@%i.service
{{/value=ws|auto}}
{{/provided-api}}
%nl
@@ -200,17 +200,43 @@ WantedBy=afm-user-session@.target
%systemd-unit wanted-by afm-user-session@.target
{{/required-permission.urn:AGL:permission::system:run-by-default}}
%end systemd-unit
-;---------------------------------------------------------------------------------
-;---- P R O V I D E D A P I S ----
-;---------------------------------------------------------------------------------
+;-------------------------------------------------------------------------------
+;---- P R O V I D E D A P I S ----
+;-------------------------------------------------------------------------------
{{#provided-api}}
-{{#value=ws|auto}}
+;-------------------------------------------------------------------------------
+;---- T H E S E R V I C E O F T H E A P I ----
+;-------------------------------------------------------------------------------
%begin systemd-unit
# auto generated by wgtpkg-unit for {{:id}} version {{:version}} target {{:#target}} of {{:idaver}}
%systemd-unit system
-%systemd-unit socket afm-api-ws-{{name}}@
+%systemd-unit service afm-api-{{name}}@
[Unit]
Description=Provides api {{name}} for user %i
+X-AFM-API-TYPE={{value}}
+Requires=afm-user-setup@%i.service
+After=afm-user-setup@%i.service
+{{#value=ws|auto}}
+Requires=afm-api-{{name}}@%i.socket
+After=afm-api-{{name}}@%i.socket
+{{/value=ws|auto}}
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+{{#value=ws|auto}}
+ExecStart=/bin/true
+{{/value=ws|auto}}
+%end systemd-unit
+;-------------------------------------------------------------------------------
+;---- T H E S O C K E T O F T H E A P I ----
+;-------------------------------------------------------------------------------
+{{#value=ws|auto}}
+%begin systemd-unit
+# auto generated by wgtpkg-unit for {{:id}} version {{:version}} target {{:#target}} of {{:idaver}}
+%systemd-unit system
+%systemd-unit socket afm-api-{{name}}@
+[Unit]
+Description=Provides websocket api {{name}} for user %i
Requires=afm-user-setup@%i.service
After=afm-user-setup@%i.service
DefaultDependencies=no
@@ -221,10 +247,6 @@ SmackLabelIPOut=System
ListenStream=@afm_users_rundir@/%i/apis/ws/{{name}}
FileDescriptorName={{name}}
Service=afm-{{#required-permission.urn:AGL:permission::public:hidden}}service{{/required-permission.urn:AGL:permission::public:hidden}}{{^required-permission.urn:AGL:permission::public:hidden}}appli{{/required-permission.urn:AGL:permission::public:hidden}}-{{:id}}--{{:ver}}--{{:#target}}@%i.service
-%nl
-[Install]
-WantedBy=afm-user-session@.target
-%systemd-unit wanted-by afm-user-session@.target
%end systemd-unit
{{/value=ws|auto}}
{{/provided-api}}
diff --git a/conf/unit/afm-unit.conf.in b/conf/unit/afm-unit.conf.in
index 20a3b50..0cbe103 100644
--- a/conf/unit/afm-unit.conf.in
+++ b/conf/unit/afm-unit.conf.in
@@ -113,14 +113,14 @@ ConditionSecurity=smack
# Automatic bound to required api
{{#required-api}}
{{#value=auto|ws}}
-BindsTo=afm-api-ws-{{name}}@%i.socket
-After=afm-api-ws-{{name}}@%i.socket
+BindsTo=afm-api-{{name}}@%i.service
+After=afm-api-{{name}}@%i.service
{{/value=auto|ws}}
{{/required-api}}
{{#provided-api}}
{{#value=ws|auto}}
-Requires=afm-api-ws-{{name}}@%i.socket
-After=afm-api-ws-{{name}}@%i.socket
+Requires=afm-api-{{name}}@%i.service
+After=afm-api-{{name}}@%i.service
{{/value=ws|auto}}
{{/provided-api}}
%nl
@@ -200,17 +200,43 @@ WantedBy=afm-user-session@.target
%systemd-unit wanted-by afm-user-session@.target
{{/required-permission.urn:AGL:permission::system:run-by-default}}
%end systemd-unit
-;---------------------------------------------------------------------------------
-;---- P R O V I D E D A P I S ----
-;---------------------------------------------------------------------------------
+;-------------------------------------------------------------------------------
+;---- P R O V I D E D A P I S ----
+;-------------------------------------------------------------------------------
{{#provided-api}}
-{{#value=ws|auto}}
+;-------------------------------------------------------------------------------
+;---- T H E S E R V I C E O F T H E A P I ----
+;-------------------------------------------------------------------------------
%begin systemd-unit
# auto generated by wgtpkg-unit for {{:id}} version {{:version}} target {{:#target}} of {{:idaver}}
%systemd-unit system
-%systemd-unit socket afm-api-ws-{{name}}@
+%systemd-unit service afm-api-{{name}}@
[Unit]
Description=Provides api {{name}} for user %i
+X-AFM-API-TYPE={{value}}
+Requires=afm-user-setup@%i.service
+After=afm-user-setup@%i.service
+{{#value=ws|auto}}
+Requires=afm-api-{{name}}@%i.socket
+After=afm-api-{{name}}@%i.socket
+{{/value=ws|auto}}
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+{{#value=ws|auto}}
+ExecStart=/bin/true
+{{/value=ws|auto}}
+%end systemd-unit
+;-------------------------------------------------------------------------------
+;---- T H E S O C K E T O F T H E A P I ----
+;-------------------------------------------------------------------------------
+{{#value=ws|auto}}
+%begin systemd-unit
+# auto generated by wgtpkg-unit for {{:id}} version {{:version}} target {{:#target}} of {{:idaver}}
+%systemd-unit system
+%systemd-unit socket afm-api-{{name}}@
+[Unit]
+Description=Provides websocket api {{name}} for user %i
Requires=afm-user-setup@%i.service
After=afm-user-setup@%i.service
DefaultDependencies=no
@@ -221,10 +247,6 @@ SmackLabelIPOut=System
ListenStream=@afm_users_rundir@/%i/apis/ws/{{name}}
FileDescriptorName={{name}}
Service=afm-{{#required-permission.urn:AGL:permission::public:hidden}}service{{/required-permission.urn:AGL:permission::public:hidden}}{{^required-permission.urn:AGL:permission::public:hidden}}appli{{/required-permission.urn:AGL:permission::public:hidden}}-{{:id}}--{{:ver}}--{{:#target}}@%i.service
-%nl
-[Install]
-WantedBy=afm-user-session@.target
-%systemd-unit wanted-by afm-user-session@.target
%end systemd-unit
{{/value=ws|auto}}
{{/provided-api}}
diff --git a/conf/unit/generate-unit-conf/afm-unit b/conf/unit/generate-unit-conf/afm-unit
index e2fb7d0..40a56fc 100644
--- a/conf/unit/generate-unit-conf/afm-unit
+++ b/conf/unit/generate-unit-conf/afm-unit
@@ -50,7 +50,9 @@ define( `IF_NOT_VALUE', `MUSTACH_IF_NOT(value=$1)')
define( `TARGET', `{{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}')
define( `UNIT_NAME_BASE', `afm-ON_PERM(`:public:hidden', `service', `appli')-{{:id}}--{{:ver}}--{{:#target}}@')
define( `UNIT_NAME_SERVICE', `UNIT_NAME_BASE%i.service')
-define( `UNIT_NAME_SOCKET_FOR', `afm-api-ws-$1@%i.socket')
+define( `UNIT_NAME_API_BASE', `afm-api-$1')
+define( `UNIT_NAME_API_SERVICE', `UNIT_NAME_API_BASE($1)@$2.service')
+define( `UNIT_NAME_API_SOCKET', `UNIT_NAME_API_BASE($1)@$2.socket')
define( `APP_DATA_DIR', `/home/%i/app-data')
define( `USER_RUN_DIR', `@afm_users_rundir@/%i')
define( `DEBUGGING_DIR', `@afm_platform_rundir@/debug')
diff --git a/conf/unit/generate-unit-conf/provided.inc b/conf/unit/generate-unit-conf/provided.inc
index ead1983..267e2ed 100644
--- a/conf/unit/generate-unit-conf/provided.inc
+++ b/conf/unit/generate-unit-conf/provided.inc
@@ -1,19 +1,63 @@
dnl vim: set filetype=sysctl.conf.m4 syntax=sysctl.conf.m4:
-;---------------------------------------------------------------------------------
-;---- P R O V I D E D A P I S ----
-;---------------------------------------------------------------------------------
+;-------------------------------------------------------------------------------
+;---- P R O V I D E D A P I S ----
+;-------------------------------------------------------------------------------
{{#provided-api}}
-{{#value=ws|auto}}
+;-------------------------------------------------------------------------------
+;---- T H E S E R V I C E O F T H E A P I ----
+;-------------------------------------------------------------------------------
%begin systemd-unit
# auto generated by wgtpkg-unit for {{:id}} version {{:version}} target {{:#target}} of {{:idaver}}
%systemd-unit system
-%systemd-unit socket afm-api-ws-{{name}}@
+%systemd-unit service UNIT_NAME_API_BASE({{name}})@
+
[Unit]
Description=Provides api {{name}} for user %i
+X-AFM-API-TYPE={{value}}
+
+Requires=afm-user-setup@%i.service
+After=afm-user-setup@%i.service
+
+{{#value=ws|auto}}
+Requires=UNIT_NAME_API_BASE({{name}})@%i.socket
+After=UNIT_NAME_API_BASE({{name}})@%i.socket
+{{/value=ws|auto}}
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+{{#value=ws|auto}}
+ExecStart=/bin/true
+{{/value=ws|auto}}
+dnl {{#value=link}}
+dnl ExecStart=/bin/ln -s {{:#metadata.install-dir}}/ USER_RUN_DIR/apis/link/{{name}}
+dnl {{/value=link}}
+
+dnl %nl
+dnl [Install]
+dnl WantedBy=afm-user-session@.target
+dnl %systemd-unit wanted-by afm-user-session@.target
+
+%end systemd-unit
+
+
+;-------------------------------------------------------------------------------
+;---- T H E S O C K E T O F T H E A P I ----
+;-------------------------------------------------------------------------------
+{{#value=ws|auto}}
+
+%begin systemd-unit
+
+# auto generated by wgtpkg-unit for {{:id}} version {{:version}} target {{:#target}} of {{:idaver}}
+
+%systemd-unit system
+%systemd-unit socket UNIT_NAME_API_BASE({{name}})@
+[Unit]
+Description=Provides websocket api {{name}} for user %i
Requires=afm-user-setup@%i.service
After=afm-user-setup@%i.service
DefaultDependencies=no
@@ -24,19 +68,13 @@ SmackLabelIPIn=System
SmackLabelIPOut=System
ListenStream=USER_RUN_DIR/apis/ws/{{name}}
FileDescriptorName={{name}}
-
Service=UNIT_NAME_SERVICE
-%nl
-[Install]
-WantedBy=afm-user-session@.target
-%systemd-unit wanted-by afm-user-session@.target
-
%end systemd-unit
-
{{/value=ws|auto}}
+
{{/provided-api}}
diff --git a/conf/unit/generate-unit-conf/service.inc b/conf/unit/generate-unit-conf/service.inc
index 88e4346..3efa975 100644
--- a/conf/unit/generate-unit-conf/service.inc
+++ b/conf/unit/generate-unit-conf/service.inc
@@ -42,14 +42,14 @@ ConditionSecurity=smack
# Automatic bound to required api
{{#required-api}}
{{#value=auto|ws}}
-BindsTo=UNIT_NAME_SOCKET_FOR({{name}})
-After=UNIT_NAME_SOCKET_FOR({{name}})
+BindsTo=UNIT_NAME_API_SERVICE({{name}},%i)
+After=UNIT_NAME_API_SERVICE({{name}},%i)
{{/value=auto|ws}}
{{/required-api}}
{{#provided-api}}
{{#value=ws|auto}}
-Requires=UNIT_NAME_SOCKET_FOR({{name}})
-After=UNIT_NAME_SOCKET_FOR({{name}})
+Requires=UNIT_NAME_API_SERVICE({{name}},%i)
+After=UNIT_NAME_API_SERVICE({{name}},%i)
{{/value=ws|auto}}
{{/provided-api}}