aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2018-11-08 14:47:10 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2018-11-08 14:47:10 +0100
commit94176d9f5f1a5d9b1f298000c2868ebab148d805 (patch)
treed04e95bd7c748b021c6559aca373e012af5c6c3b
parent44c70fd80a3ff8931aa97555ceaf5ed578e4f8be (diff)
afm-unit: Export new variables
Export the new variables: - AFM_ID: the identifier of the application - AFM_WORKDIR: the workdir of the application - AFM_WSAPI_DIR: the directory where APIs can be accessed Change-Id: I79b46754f84161a36d9a13dd79bc94e777c854fe Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--conf/unit/afm-unit-debug.conf.in4
-rw-r--r--conf/unit/afm-unit.conf.in3
-rw-r--r--conf/unit/generate-unit-conf/afm-unit3
-rw-r--r--conf/unit/generate-unit-conf/binder.inc4
-rw-r--r--conf/unit/generate-unit-conf/provided-api.inc2
-rw-r--r--conf/unit/generate-unit-conf/provided-binding.inc2
-rw-r--r--conf/unit/generate-unit-conf/service.inc4
7 files changed, 16 insertions, 6 deletions
diff --git a/conf/unit/afm-unit-debug.conf.in b/conf/unit/afm-unit-debug.conf.in
index 7ffeb2f..582e723 100644
--- a/conf/unit/afm-unit-debug.conf.in
+++ b/conf/unit/afm-unit-debug.conf.in
@@ -146,7 +146,10 @@ Slice=user-%i.slice
%nl
WorkingDirectory=-/home/%i/app-data/{{:id}}
ExecStartPre=/bin/mkdir -p /home/%i/app-data/{{:id}}
+Environment=AFM_ID={{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}
Environment=AFM_APP_INSTALL_DIR={{:#metadata.install-dir}}
+Environment=AFM_WORKDIR=/home/%i/app-data/{{:id}}
+Environment=AFM_WSAPI_DIR=@afm_users_rundir@/%i/apis/ws
Environment=PATH=/usr/sbin:/usr/bin:/sbin:/bin:{{:#metadata.install-dir}}/bin
Environment=LD_LIBRARY_PATH={{:#metadata.install-dir}}/lib
Environment=XDG_DATA_HOME=/home/%i/app-data/{{:id}}
@@ -155,7 +158,6 @@ Environment=XDG_CACHE_HOME=/home/%i/app-data/{{:id}}
Environment=XDG_RUNTIME_DIR=@afm_users_rundir@/%i
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=@afm_users_rundir@/%i/bus
; Needed to enable debug
-Environment=AFM_ID={{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}
EnvironmentFile=-@afm_platform_rundir@/debug/{{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}.env
SyslogIdentifier=afbd-{{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}
StandardInput=null
diff --git a/conf/unit/afm-unit.conf.in b/conf/unit/afm-unit.conf.in
index 3569790..7c7d36a 100644
--- a/conf/unit/afm-unit.conf.in
+++ b/conf/unit/afm-unit.conf.in
@@ -146,7 +146,10 @@ Slice=user-%i.slice
%nl
WorkingDirectory=-/home/%i/app-data/{{:id}}
ExecStartPre=/bin/mkdir -p /home/%i/app-data/{{:id}}
+Environment=AFM_ID={{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}
Environment=AFM_APP_INSTALL_DIR={{:#metadata.install-dir}}
+Environment=AFM_WORKDIR=/home/%i/app-data/{{:id}}
+Environment=AFM_WSAPI_DIR=@afm_users_rundir@/%i/apis/ws
Environment=PATH=/usr/sbin:/usr/bin:/sbin:/bin:{{:#metadata.install-dir}}/bin
Environment=LD_LIBRARY_PATH={{:#metadata.install-dir}}/lib
Environment=XDG_DATA_HOME=/home/%i/app-data/{{:id}}
diff --git a/conf/unit/generate-unit-conf/afm-unit b/conf/unit/generate-unit-conf/afm-unit
index 99d986d..7a47f08 100644
--- a/conf/unit/generate-unit-conf/afm-unit
+++ b/conf/unit/generate-unit-conf/afm-unit
@@ -58,6 +58,9 @@ define( `UNIT_NAME_BINDING_SERVICE', `UNIT_NAME_BINDING_BASE($1)@$2.service')
define( `APP_DATA_DIR', `/home/%i/app-data')
define( `USER_RUN_DIR', `@afm_users_rundir@/%i')
define( `DEBUGGING_DIR', `@afm_platform_rundir@/debug')
+define( `API_PATH', `USER_RUN_DIR/apis')
+define( `API_PATH_WS', `API_PATH/ws')
+define( `API_PATH_LINK', `API_PATH/link')
-----------------------------------------------------------------------
--
diff --git a/conf/unit/generate-unit-conf/binder.inc b/conf/unit/generate-unit-conf/binder.inc
index 8f3bd7d..1a5e71f 100644
--- a/conf/unit/generate-unit-conf/binder.inc
+++ b/conf/unit/generate-unit-conf/binder.inc
@@ -31,7 +31,7 @@ ELSE \
ENDIF \
ON_PERM(:public:applications:read, --alias=/icons:{{:#metadata.icons-dir}}) \
{{#required-api}} \
- ON_VALUE(auto|ws, --ws-client=unix:USER_RUN_DIR/apis/ws/{{name}}) \
+ ON_VALUE(auto|ws, --ws-client=unix:API_PATH_WS/{{name}}) \
ON_VALUE(dbus, --dbus-client={{name}}) \
ON_VALUE(cloud, --cloud-client={{name}}) \
ON_VALUE(local, --binding={{:#metadata.install-dir}}/{{name}}) \
@@ -39,7 +39,7 @@ ENDIF \
{{/required-api}} \
{{#required-binding}} \
ON_VALUE(local, --binding={{:#metadata.install-dir}}/{{name}}) \
- ON_VALUE(extern, --binding=USER_RUN_DIR/apis/link/{{name}}) \
+ ON_VALUE(extern, --binding=API_PATH_LINK/{{name}}) \
{{/required-binding}} \
{{#provided-api}} \
ON_VALUE(auto|ws, --ws-server=sd:{{name}}) \
diff --git a/conf/unit/generate-unit-conf/provided-api.inc b/conf/unit/generate-unit-conf/provided-api.inc
index eb04181..db5f125 100644
--- a/conf/unit/generate-unit-conf/provided-api.inc
+++ b/conf/unit/generate-unit-conf/provided-api.inc
@@ -58,7 +58,7 @@ DefaultDependencies=no
SmackLabel=*
SmackLabelIPIn=System
SmackLabelIPOut=System
-ListenStream=USER_RUN_DIR/apis/ws/{{name}}
+ListenStream=API_PATH_WS/{{name}}
FileDescriptorName={{name}}
Service=UNIT_NAME_SERVICE
diff --git a/conf/unit/generate-unit-conf/provided-binding.inc b/conf/unit/generate-unit-conf/provided-binding.inc
index c60b0dc..64c453d 100644
--- a/conf/unit/generate-unit-conf/provided-binding.inc
+++ b/conf/unit/generate-unit-conf/provided-binding.inc
@@ -24,7 +24,7 @@ After=afm-user-setup@%i.service
[Service]
Type=oneshot
RemainAfterExit=yes
-ExecStart=/bin/ln -sf {{:#metadata.install-dir}}/{{value}} USER_RUN_DIR/apis/link/{{name}}
+ExecStart=/bin/ln -sf {{:#metadata.install-dir}}/{{value}} API_PATH_LINK/{{name}}
%end systemd-unit
diff --git a/conf/unit/generate-unit-conf/service.inc b/conf/unit/generate-unit-conf/service.inc
index 5b146ee..961a262 100644
--- a/conf/unit/generate-unit-conf/service.inc
+++ b/conf/unit/generate-unit-conf/service.inc
@@ -81,7 +81,10 @@ ON_PERM(:public:syscall:clock, , SystemCallFilter=~@clock)
WorkingDirectory=-APP_DATA_DIR/{{:id}}
ExecStartPre=/bin/mkdir -p APP_DATA_DIR/{{:id}}
+Environment=AFM_ID=TARGET
Environment=AFM_APP_INSTALL_DIR={{:#metadata.install-dir}}
+Environment=AFM_WORKDIR=APP_DATA_DIR/{{:id}}
+Environment=AFM_WSAPI_DIR=API_PATH_WS
Environment=PATH=/usr/sbin:/usr/bin:/sbin:/bin:{{:#metadata.install-dir}}/bin
Environment=LD_LIBRARY_PATH={{:#metadata.install-dir}}/lib
Environment=XDG_DATA_HOME=APP_DATA_DIR/{{:id}}
@@ -92,7 +95,6 @@ Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=USER_RUN_DIR/bus
IF_AGL_DEVEL
; Needed to enable debug
-Environment=AFM_ID=TARGET
EnvironmentFile=-DEBUGGING_DIR/TARGET.env
ENDIF