1 From c7f9d14e38a1b6d40b2fffa01433a3025eff9abd Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Jos=C3=A9=20Bollo?= <jose.bollo@iot.bzh>
3 Date: Tue, 26 Nov 2019 12:34:39 +0100
4 Subject: [PATCH 14/14] Ensure post install initialization of database
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Creation of the database was made during image creation,
10 leading to issue with SOTA. This adds the creation on
11 need before launching the service.
13 Change-Id: Idfd0676bd87d39f7c10eaafd63f3a318f675c972
14 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
16 db/CMakeLists.txt | 14 ++++++--------
17 db/security-manager-setup | 14 ++++++++++++++
18 systemd/security-manager.service.in | 1 +
19 3 files changed, 21 insertions(+), 8 deletions(-)
20 create mode 100644 db/security-manager-setup
22 diff --git a/db/CMakeLists.txt b/db/CMakeLists.txt
23 index d7af1a0..dcf5bc8 100644
24 --- a/db/CMakeLists.txt
25 +++ b/db/CMakeLists.txt
27 -SET(TARGET_DB "$(DB_FILENAME)")
30 - OUTPUT ${TARGET_DB} ${TARGET_DB}-journal
31 - COMMAND sqlite3 ${TARGET_DB} <db.sql
33 + OUTPUT .security-manager-setup
34 + COMMAND sed '/--DB\.SQL--/r db.sql' security-manager-setup > .security-manager-setup
35 + DEPENDS security-manager-setup db.sql
38 # Add a dummy build target to trigger building of ${TARGET_DB}
39 -ADD_CUSTOM_TARGET(DB ALL DEPENDS ${TARGET_DB})
40 +ADD_CUSTOM_TARGET(DB ALL DEPENDS .security-manager-setup)
42 -INSTALL(FILES ${TARGET_DB} DESTINATION ${DB_INSTALL_DIR})
43 -INSTALL(FILES ${TARGET_DB}-journal DESTINATION ${DB_INSTALL_DIR})
44 +INSTALL(PROGRAMS .security-manager-setup DESTINATION ${BIN_INSTALL_DIR})
45 diff --git a/db/security-manager-setup b/db/security-manager-setup
47 index 0000000..5675baf
49 +++ b/db/security-manager-setup
53 +if test -f "$1"; then exit; fi
55 +dbdir="$(dirname "$1")"
56 +dbfile="$(basename "$1")"
61 +sqlite3 "$dbfile" << END-OF-CAT
65 diff --git a/systemd/security-manager.service.in b/systemd/security-manager.service.in
66 index 23fd1b2..2bf97d7 100644
67 --- a/systemd/security-manager.service.in
68 +++ b/systemd/security-manager.service.in
69 @@ -3,5 +3,6 @@ Description=Start the security manager
73 +ExecStartPre=@BIN_INSTALL_DIR@/.security-manager-setup @DB_INSTALL_DIR@/@DB_FILENAME@
74 ExecStart=@BIN_INSTALL_DIR@/security-manager
75 Sockets=security-manager.socket