cloudconnector: add init service
Signed-off-by: Isaac Hermida <isaac.hermida@digi.com> Signed-off-by: David Escalona <david.escalona@digi.com> (cherry picked from commit ccc9211d00dad7be6cb2c2d0cf179a62563e26c6)
This commit is contained in:
parent
91c9c06cd0
commit
d7f3991209
|
|
@ -15,18 +15,41 @@ CC_GITHUB = "gitsm://github.com/digi-embedded/cc_dey.git;protocol=https"
|
|||
|
||||
CC_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${CC_STASH}', '${CC_GITHUB}', d)}"
|
||||
|
||||
SRC_URI = "${CC_GIT_URI};branch=${SRCBRANCH}"
|
||||
SRC_URI = " \
|
||||
${CC_GIT_URI};branch=${SRCBRANCH} \
|
||||
file://cloud-connector-init \
|
||||
file://cloud-connector.service \
|
||||
"
|
||||
|
||||
S = "${WORKDIR}/git"
|
||||
|
||||
inherit pkgconfig
|
||||
inherit pkgconfig systemd update-rc.d
|
||||
|
||||
do_install() {
|
||||
oe_runmake DESTDIR=${D} install
|
||||
|
||||
if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
|
||||
# Install systemd unit files
|
||||
install -d ${D}${systemd_unitdir}/system
|
||||
install -m 0644 ${WORKDIR}/cloud-connector.service ${D}${systemd_unitdir}/system/
|
||||
fi
|
||||
|
||||
install -d ${D}${sysconfdir}/init.d/
|
||||
install -m 755 ${WORKDIR}/cloud-connector-init ${D}${sysconfdir}/cloud-connector
|
||||
ln -sf /etc/cloud-connector ${D}${sysconfdir}/init.d/cloud-connector
|
||||
}
|
||||
|
||||
INITSCRIPT_NAME = "cloud-connector"
|
||||
SYSTEMD_SERVICE:${PN} = "cloud-connector.service"
|
||||
|
||||
PACKAGES =+ "${PN}-cert"
|
||||
|
||||
FILES:${PN} += " \
|
||||
${systemd_unitdir}/system/cloud-connector.service \
|
||||
${sysconfdir}/cloud-connector \
|
||||
${sysconfdir}/init.d/cloud-connector \
|
||||
"
|
||||
|
||||
FILES:${PN}-cert = "${sysconfdir}/ssl/certs/Digi_Int-ca-cert-public.crt"
|
||||
|
||||
CONFFILES:${PN} += "${sysconfdir}/cc.conf"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/sh
|
||||
#===============================================================================
|
||||
#
|
||||
# Copyright (C) 2022 by Digi International Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 as published by
|
||||
# the Free Software Foundation.
|
||||
#
|
||||
#
|
||||
# !Description: Initialize Cloud Connector service
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
# Source function library: status, pidofproc and killproc
|
||||
. /etc/init.d/functions
|
||||
|
||||
readonly CC_BINARY="/usr/bin/cloud-connector"
|
||||
readonly STOP_TIMEOUT="5"
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
status ${CC_BINARY} > /dev/null || ${CC_BINARY} -d > /dev/null 2>&1
|
||||
;;
|
||||
stop)
|
||||
# try to stop gracefully
|
||||
killproc ${CC_BINARY} >/dev/null 2>&1
|
||||
for i in $(seq ${STOP_TIMEOUT}); do
|
||||
pid=$(pidofproc ${CC_BINARY}) || break
|
||||
if [ "${i}" -eq ${STOP_TIMEOUT} ]; then
|
||||
kill -KILL "${pid}" >/dev/null 2>&1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
sleep 1
|
||||
$0 start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
[Unit]
|
||||
Description=Cloud Connector service initialization
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
ExecStart=/etc/cloud-connector start
|
||||
ExecStop=/etc/cloud-connector stop
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Loading…
Reference in New Issue