diff --git a/utils/cloud_dispatcher/CMakeLists.txt b/utils/cloud_dispatcher/CMakeLists.txt index d3e8c563..73901312 100644 --- a/utils/cloud_dispatcher/CMakeLists.txt +++ b/utils/cloud_dispatcher/CMakeLists.txt @@ -1,11 +1,24 @@ +project(picloud) +import_version(${PROJECT_NAME} pip) +set_deploy_property(${PROJECT_NAME} + LABEL "PIP Cloud dispatcher" + FULLNAME "${pip_DOMAIN}.picloud" + COMPANY "${pip_COMPANY}" + INFO "PIP Cloud dispatcher") +make_rc(${PROJECT_NAME} RC) list(APPEND PIP_UTILS_LIST "picloud") set(PIP_UTILS_LIST ${PIP_UTILS_LIST} PARENT_SCOPE) file(GLOB CPPS "*.cpp") file(GLOB HDRS "*.h") -add_executable(picloud ${CPPS} ${HDRS}) -target_link_libraries(picloud pip pip_cloud pip_console) +add_executable(${PROJECT_NAME} ${CPPS} ${HDRS} ${RC}) +target_link_libraries(${PROJECT_NAME} pip pip_cloud pip_console) if (DEFINED LIB) - install(TARGETS picloud DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) + install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) else() - install(TARGETS picloud DESTINATION bin) + install(TARGETS ${PROJECT_NAME} DESTINATION bin) endif() +deploy_target(${PROJECT_NAME} + DEPLOY_DIR ${CMAKE_CURRENT_BINARY_DIR} + DESTINATION ${ROOT_DIR}/release + DEB_ADD_SERVICE + ) diff --git a/utils/cloud_dispatcher/debian-service/DEBIAN/postinst b/utils/cloud_dispatcher/debian-service/DEBIAN/postinst new file mode 100644 index 00000000..351ee5cd --- /dev/null +++ b/utils/cloud_dispatcher/debian-service/DEBIAN/postinst @@ -0,0 +1,16 @@ +#!/bin/sh +set -e + +action=$1 +version=$2 + +if [ "$action" = "configure" ]; then + cp /opt/org.SHS.picloud/picloud.service /etc/systemd/system/ + systemctl --system daemon-reload >/dev/null || true + systemctl enable shs-server >/dev/null || true + systemctl start shs-server >/dev/null || true +fi + +#dpkg-maintscript-helper rm_conffile /etc/network/if-up.d/openssh-server 1:7.9p1-1~ -- "$@" + +exit 0 diff --git a/utils/cloud_dispatcher/debian-service/DEBIAN/postrm b/utils/cloud_dispatcher/debian-service/DEBIAN/postrm new file mode 100644 index 00000000..cb5c4099 --- /dev/null +++ b/utils/cloud_dispatcher/debian-service/DEBIAN/postrm @@ -0,0 +1,20 @@ +#!/bin/sh +set -e + +action=$1 + +#if [ "$action" = "purge" ] ; then +# +#fi +#dpkg-maintscript-helper rm_conffile /etc/network/if-up.d/openssh-server 1:7.9p1-1~ -- "$@" + +if [ "$action" = "remove" ]; then + systemctl disable picloud >/dev/null || true + rm /etc/systemd/system/picloud.service + systemctl --system daemon-reload >/dev/null || true + if which deluser >/dev/null 2>&1; then + deluser --quiet shs > /dev/null || true + fi +fi + +exit 0 diff --git a/utils/cloud_dispatcher/debian-service/DEBIAN/preinst b/utils/cloud_dispatcher/debian-service/DEBIAN/preinst new file mode 100644 index 00000000..812c444c --- /dev/null +++ b/utils/cloud_dispatcher/debian-service/DEBIAN/preinst @@ -0,0 +1,25 @@ +#!/bin/sh +set -e + +action=$1 +version=$2 + +if [ "$action" = "install" ]; then + gr=dialout + if grep -q gpio /etc/group; then + gr=$gr,gpio + fi + useradd --system --create-home --home-dir /var/lib/shs --shell /usr/sbin/nologin --groups $gr shs +fi +#if [ "$action" = upgrade ] || [ "$action" = install ] +#then +# if dpkg --compare-versions "$version" lt 1:5.5p1-6 && \ +# [ -d /run/sshd ]; then +# # make sure /run/sshd is not removed on upgrades +# touch /run/sshd/.placeholder +# fi +#fi + +#dpkg-maintscript-helper rm_conffile /etc/network/if-up.d/openssh-server 1:7.9p1-1~ -- "$@" + +exit 0 diff --git a/utils/cloud_dispatcher/debian-service/DEBIAN/prerm b/utils/cloud_dispatcher/debian-service/DEBIAN/prerm new file mode 100644 index 00000000..9ab40b38 --- /dev/null +++ b/utils/cloud_dispatcher/debian-service/DEBIAN/prerm @@ -0,0 +1,10 @@ +#!/bin/sh +set -e + +action=$1 + +#dpkg-maintscript-helper rm_conffile /etc/network/if-up.d/openssh-server 1:7.9p1-1~ -- "$@" + +systemctl stop picloud >/dev/null || true + +exit 0 diff --git a/utils/cloud_dispatcher/debian-service/picloud.service b/utils/cloud_dispatcher/debian-service/picloud.service new file mode 100644 index 00000000..b8c56d16 --- /dev/null +++ b/utils/cloud_dispatcher/debian-service/picloud.service @@ -0,0 +1,18 @@ +[Unit] +Description=PIP Cloud dispatcher + +[Service] +Type=simple +WorkingDirectory=/var/lib/shs + +User=shs +Group=shs + +ExecStart=/opt/org.SHS.picloud/picloud + +TimeoutStopSec=30 +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target