Improve environment setting
authorJosé Bollo <jose.bollo@iot.bzh>
Wed, 19 Apr 2017 09:32:23 +0000 (11:32 +0200)
committerJosé Bollo <jose.bollo@iot.bzh>
Wed, 19 Apr 2017 16:17:43 +0000 (18:17 +0200)
Some environment variable were set in the configuration files.
This wasn't a valuable solution. Allowing now system tning to
put environment variables in files of /etc/afm/unit.env.d
is much more flexible.

Change-Id: I1796061c9055a2860f0bbab340aa3a6e7b85dd3d
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
conf/CMakeLists.txt
conf/afm-system-daemon.service.in [moved from conf/afm-system-daemon.service with 100% similarity]
conf/afm-unit.conf.in [moved from conf/afm-unit.conf with 99% similarity]
conf/afm-user-daemon.service.in [moved from conf/afm-user-daemon.service with 87% similarity]

index d8611e0..cf3d3ec 100644 (file)
@@ -19,6 +19,9 @@
 cmake_minimum_required(VERSION 2.8)
 
 configure_file(afm-launch.conf.in afm-launch.conf)
+configure_file(afm-unit.conf.in afm-unit.conf)
+configure_file(afm-system-daemon.service.in afm-system-daemon.service)
+configure_file(afm-user-daemon.service.in afm-user-daemon.service)
 
 if(NOT USE_SDK)
        set(SYSCONFDIR_DBUS_SYSTEM ${CMAKE_INSTALL_SYSCONFDIR}/dbus-1/system.d CACHE STRING "Path to dbus system configuration files")
@@ -27,10 +30,11 @@ if(NOT USE_SDK)
        set(UNITDIR_USER           ${CMAKE_INSTALL_LIBDIR}/systemd/user CACHE STRING "Path to systemd system unit files")
 
        install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/afm-system-daemon.conf    DESTINATION ${SYSCONFDIR_DBUS_SYSTEM})
-       install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/afm-system-daemon.service DESTINATION ${UNITDIR_SYSTEM})
+       install(FILES ${CMAKE_CURRENT_BINARY_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-user-daemon.service   DESTINATION ${UNITDIR_USER})
        install(FILES ${CMAKE_CURRENT_BINARY_DIR}/afm-launch.conf           DESTINATION ${afm_confdir})
-       install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/afm-unit.conf             DESTINATION ${afm_confdir})
+       install(FILES ${CMAKE_CURRENT_BINARY_DIR}/afm-unit.conf             DESTINATION ${afm_confdir})
+       install(DIRECTORY DESTINATION ${afm_confdir}/unit.env.d)
 endif()
 
similarity index 99%
rename from conf/afm-unit.conf
rename to conf/afm-unit.conf.in
index 6712424..fc0c006 100644 (file)
@@ -114,6 +114,7 @@ After=afm-api-ws-{{name}}
 %nl
 
 [Service]
+EnvironmentFile=-@afm_confdir@/unit.env.d/*
 SmackProcessLabel=User::App::{{id}}
 SuccessExitStatus=0 SIGKILL
 
similarity index 87%
rename from conf/afm-user-daemon.service
rename to conf/afm-user-daemon.service.in
index 6b5c1d8..f536c82 100644 (file)
@@ -6,7 +6,7 @@ Type=dbus
 BusName=org.AGL.afm.user          
 ExecStart=/usr/bin/afm-user-daemon --user-dbus=unix:path=%t/bus
 Environment=AFM_APP_INSTALL_DIR=%%r
-Environment=LD_PRELOAD=/usr/lib/libEGL.so
+EnvironmentFile=-@afm_confdir@/unit.env.d/*
 Restart=on-failure
 RestartSec=5