Skip to content

Commit 508d74f

Browse files
committed
services: add support for sysv init scripts
Add support for sysv init scripts. Install both systemd and sysv scripts and let the DISTRO_FEATURES install the appropriate handler. Signed-off-by: Paul Barrette <[email protected]>
1 parent 8a828ea commit 508d74f

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

recipes-iot/python/device-cloud-common.inc

+15-13
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ PACKAGES =+ "${PN}-systemd"
4848
SYSTEMD_SERVICE_${PN}-systemd += "device-manager.service"
4949
SYSTEMD_PACKAGES = "${PN}-systemd"
5050

51+
INITSCRIPT_NAME = "device-manager-sysv-init"
52+
INITSCRIPT_PARAMS = "start 10 2 3 4 5 . stop 32 0 1 6 ."
53+
5154
# device-cloud-python must be able to coexsit with previous HDC versions. So, install
5255
# into its own namespace.
5356
do_install_append() {
@@ -59,11 +62,23 @@ do_install_append() {
5962
install -d ${D}/${BIN_DIR}
6063
install -d ${D}${systemd_unitdir}/system/
6164
install -d ${D}/${sysconfdir}/sudoers.d
65+
install -d ${D}${sysconfdir}/init.d
6266

67+
# sudoers file
6368
install -m 0400 "${B}/share/sudoers.d/device-cloud" "${D}/${sysconfdir}/sudoers.d/device-cloud"
69+
70+
# --------------------------------------------------------
71+
# install both sysv and systemd. Let the distro features
72+
# --------------------------------------------------------
73+
74+
# systemd service
6475
cat ${B}/share/device-manager.service.in | sed -e "s|%user%|${DC_USER}|" > "${B}/share/device-manager.service"
6576
install -m 0644 "${B}/share/device-manager.service" ${D}${systemd_unitdir}/system/
6677

78+
# sysv init script
79+
cat ${B}/share/device-manager-sysv-init.in | sed -e "s|%user%|${DC_USER}|" > "${B}/share/device-manager-sysv-init"
80+
install -m 0755 "${B}/share/device-manager-sysv-init" ${D}${sysconfdir}/init.d/device-manager-sysv-init
81+
6782
# update the working directory
6883
sed -i "s|^#WorkingDirectory.*|WorkingDirectory=${VAR_DIR}|" ${D}${systemd_unitdir}/system/device-manager.service
6984

@@ -87,25 +102,12 @@ do_install_append() {
87102
install -m 0755 "${B}/share/snapshot_util.py" ${D}${BIN_DIR}
88103
fi
89104

90-
91105
install -m 644 "${B}/COPYING.txt" ${D}/${SHARE_DIR}
92106
cp -r ${B}/demo ${D}/${SHARE_DIR}
93107
cp ${B}/README* ${D}/${SHARE_DIR}
94108
cp -r ${B}/share/example-ota-packages ${D}/${SHARE_DIR}
95109

96-
# change the #! line to use python not python3 which is the default
97-
sed -i "s/env python\?/env ${PYTHON_PN}/" ${D}/${SHARE_DIR}/demo/*.py
98-
99-
# fix python version, this is python 2.x, so check for python3
100-
for i in device_manager.py generate_config.py validate_script.py validate_app.py; do
101-
{
102-
echo "converting ${S}/${i} to ${B}/${i}"
103-
sed -i "s/env python\?/env ${PYTHON_PN}/" ${B}/${i}
104-
} done
105-
106-
# TODO: update the demo app config/runtime dirs
107110
# update the runtime dir in iot.cfg
108-
# update the config dir
109111
sed -i "s|:\"runtime\"|:\"${VAR_DIR}\"|" ${B}/iot.cfg
110112
sed -i "s|default_cfg_dir = \".\"|default_cfg_dir = \"${ETC_DIR}\"|" ${B}/device_manager.py
111113
sed -i "s|systemd_controlled = False|systemd_controlled = True|" ${B}/device_manager.py

recipes-iot/python/python-device-cloud_1.0.bb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# License: MIT
44
#
55
# Python 2
6-
inherit setuptools systemd
6+
inherit setuptools update-rc.d systemd
77

88
# pull in the user id details
99
require device-cloud-user.inc

recipes-iot/python/python3-device-cloud_1.0.bb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# License: MIT
44
#
55
# Python 3
6-
inherit setuptools3 systemd
6+
inherit setuptools3 update-rd.d systemd
77

88
# pull in the user id details
99
require device-cloud-user.inc

0 commit comments

Comments
 (0)