aboutsummaryrefslogtreecommitdiffstats
path: root/conf
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2019-05-03 18:43:21 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2019-05-14 10:58:01 +0200
commitcc937529cdf8fad47b9b988fe205406f75d61acd (patch)
tree40e47ef34ab2269aa3602e5d4c3957ec1f617846 /conf
parent2db5d235fe4819c622d22282f5945ef4f13f6372 (diff)
Refactor of system and user setuphalibut_7.99.1halibut/7.99.17.99.1
Since a long time, the creation of the user and system run environment was made by a sub-optimal, hardly maintainable and false-error generating. This change puts the user and system setup in separate shell scripts. This makes them more easy to maintain, update or tune. This facility will useful for further evolution. Bug-AGL: SPEC-1016 Change-Id: Iede81a659eacf4e5c21c561a33d300408e1bd058 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'conf')
-rw-r--r--conf/system/CMakeLists.txt17
-rw-r--r--conf/system/afm-system-setup.service9
-rw-r--r--conf/system/afm-system-setup.service.in6
-rw-r--r--conf/system/afm-system-setup.sh.in16
-rw-r--r--conf/system/afm-user-setup.sh.in28
-rw-r--r--conf/system/afm-user-setup@.service14
-rw-r--r--conf/system/afm-user-setup@.service.in7
7 files changed, 71 insertions, 26 deletions
diff --git a/conf/system/CMakeLists.txt b/conf/system/CMakeLists.txt
index cdece83..4f77f93 100644
--- a/conf/system/CMakeLists.txt
+++ b/conf/system/CMakeLists.txt
@@ -19,8 +19,12 @@
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-system-daemon.socket.in afm-system-daemon.socket)
+configure_file(afm-system-setup.service.in afm-system-setup.service)
+configure_file(afm-system-setup.sh.in afm-system-setup.sh)
configure_file(afm-api-afm-main@.service.in afm-api-afm-main@.service)
+configure_file(afm-user-setup@.service.in afm-user-setup@.service)
+configure_file(afm-user-setup.sh.in afm-user-setup.sh)
if(NOT USE_SDK)
set(SYSCONFDIR_DBUS_SYSTEM ${CMAKE_INSTALL_SYSCONFDIR}/dbus-1/system.d CACHE STRING "Path to dbus system configuration files")
@@ -34,12 +38,19 @@ if(NOT USE_SDK)
${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
+ ${CMAKE_CURRENT_BINARY_DIR}/afm-system-setup.service
${CMAKE_CURRENT_SOURCE_DIR}/afm-user-session@.service
${CMAKE_CURRENT_SOURCE_DIR}/afm-user-session@.target
- ${CMAKE_CURRENT_SOURCE_DIR}/afm-user-setup@.service
+ ${CMAKE_CURRENT_BINARY_DIR}/afm-user-setup@.service
DESTINATION
${UNITDIR_SYSTEM}
)
+ install(
+ PROGRAMS
+ ${CMAKE_CURRENT_BINARY_DIR}/afm-user-setup.sh
+ ${CMAKE_CURRENT_BINARY_DIR}/afm-system-setup.sh
+ DESTINATION
+ ${afm_libexecdir}
+ )
endif()
diff --git a/conf/system/afm-system-setup.service b/conf/system/afm-system-setup.service
deleted file mode 100644
index d624aeb..0000000
--- a/conf/system/afm-system-setup.service
+++ /dev/null
@@ -1,9 +0,0 @@
-[Unit]
-Description=Initiate afm-system-setup
-Before=weston.service afs-supervisor.service afm-system-daemon.service
-[Service]
-Type=oneshot
-ExecStart=-/bin/sh -c "/bin/mkdir -m 755 /run/platform; /usr/bin/chsmack -a '*' /run/platform"
-ExecStart=-/bin/sh -c "/bin/mkdir -m 755 /run/platform/display; /usr/bin/chsmack -a '*' /run/platform/display"
-ExecStart=-/bin/sh -c "/bin/mkdir -m 755 /run/platform/apis; /usr/bin/chsmack -a '*' /run/platform/apis"
-ExecStart=-/bin/sh -c "/bin/mkdir -m 755 /run/platform/apis/ws; /usr/bin/chsmack -a '*' /run/platform/apis/ws"
diff --git a/conf/system/afm-system-setup.service.in b/conf/system/afm-system-setup.service.in
new file mode 100644
index 0000000..694ac2d
--- /dev/null
+++ b/conf/system/afm-system-setup.service.in
@@ -0,0 +1,6 @@
+[Unit]
+Description=Initiate afm-system-setup
+Before=weston.service afs-supervisor.service afm-system-daemon.service
+[Service]
+Type=oneshot
+ExecStart=-@afm_libexecdir@/afm-system-setup.sh
diff --git a/conf/system/afm-system-setup.sh.in b/conf/system/afm-system-setup.sh.in
new file mode 100644
index 0000000..2af411c
--- /dev/null
+++ b/conf/system/afm-system-setup.sh.in
@@ -0,0 +1,16 @@
+#!bin/sh
+
+pdir=@afm_platform_rundir@
+
+dodir() {
+ if ! test -e $1; then
+ mkdir -m 755 $1
+ chsmack -a '*' $1
+ fi
+}
+
+dodir $pdir
+dodir $pdir/display
+dodir $pdir/apis
+dodir $pdir/apis/ws
+
diff --git a/conf/system/afm-user-setup.sh.in b/conf/system/afm-user-setup.sh.in
new file mode 100644
index 0000000..24795ae
--- /dev/null
+++ b/conf/system/afm-user-setup.sh.in
@@ -0,0 +1,28 @@
+#!bin/sh
+
+uid=$1
+udir=/run/user/$uid
+
+dodir() {
+ if ! test -e $1; then
+ mkdir -m 700 $1
+ chown $uid:$uid $1
+ chsmack -a '*' $1
+ fi
+}
+
+dodir $udir
+dodir $udir/apis
+dodir $udir/apis/ws
+dodir $udir/apis/link
+
+doln() {
+ if ! test -e $2; then
+ ln -sf $1 $2
+ chown -h $uid:$uid $2
+ chsmack -a '*' $2
+ fi
+}
+
+doln @afm_platform_rundir@/display/wayland-0 $udir/wayland-0
+
diff --git a/conf/system/afm-user-setup@.service b/conf/system/afm-user-setup@.service
deleted file mode 100644
index f23dcd3..0000000
--- a/conf/system/afm-user-setup@.service
+++ /dev/null
@@ -1,14 +0,0 @@
-[Unit]
-Description=Initiate afm-user-setup %i
-After=user@%i.service
-[Service]
-Type=oneshot
-StartLimitInterval=0
-ExecStart=-/bin/sh -c "/bin/mkdir /run/user/%i; /bin/chown %i:%i /run/user/%i; /usr/bin/chsmack -a '*' /run/user/%i"
-ExecStart=-/bin/sh -c "/bin/mkdir /run/user/%i/apis; /bin/chown %i:%i /run/user/%i/apis; /usr/bin/chsmack -a '*' /run/user/%i/apis"
-ExecStart=-/bin/sh -c "/bin/mkdir /run/user/%i/apis/ws; /bin/chown %i:%i /run/user/%i/apis/ws; /usr/bin/chsmack -a '*' /run/user/%i/apis/ws"
-ExecStart=-/bin/sh -c "/bin/mkdir /run/user/%i/apis/link; /bin/chown %i:%i /run/user/%i/apis/link; /usr/bin/chsmack -a '*' /run/user/%i/apis/link"
-ExecStart=-/bin/sh -c "/bin/ln -sf /run/platform/display/wayland-0 /run/user/%i/wayland-0; /bin/chown -h %i:%i /run/user/%i/wayland-0; /usr/bin/chsmack -a '*' /run/user/%i/wayland-0"
-
-
-
diff --git a/conf/system/afm-user-setup@.service.in b/conf/system/afm-user-setup@.service.in
new file mode 100644
index 0000000..86c0422
--- /dev/null
+++ b/conf/system/afm-user-setup@.service.in
@@ -0,0 +1,7 @@
+[Unit]
+Description=Initiate afm-user-setup %i
+After=user@%i.service
+[Service]
+Type=oneshot
+StartLimitInterval=0
+ExecStart=-@afm_libexecdir@/afm-user-setup.sh %i