openssh: align the service behavior with stx 3.0
[pti/rtp.git] / meta-stx / recipes-connectivity / openssh / openssh_7.%.bbappend
1 #
2 ## Copyright (C) 2019 Wind River Systems, Inc.
3 #
4 #  Licensed under the Apache License, Version 2.0 (the "License");
5 #  you may not use this file except in compliance with the License.
6 #  You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #  Unless required by applicable law or agreed to in writing, software
11 #  distributed under the License is distributed on an "AS IS" BASIS,
12 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #  See the License for the specific language governing permissions and
14 #  limitations under the License.
15
16 FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
17
18 SRC_URI += "\
19     file://stx/sshd.init \
20     file://stx/sshd-keygen \
21     file://stx/sshd-keygen.service \
22     file://stx/sshd.service \
23     file://stx/sshd.sysconfig \
24 "
25
26 SYSTEMD_SERVICE_${PN}-sshd = "sshd.service"
27
28 do_install_append () {
29     rm -f ${D}${systemd_system_unitdir}/sshd.socket
30     rm -f ${D}${systemd_system_unitdir}/sshd@service.socket
31     rm -f ${D}${systemd_system_unitdir}/sshdgenkeys.service
32
33     install -d ${D}/${sysconfdir}/init.d/
34     install -m 755 ${WORKDIR}/stx/sshd.init ${D}/${sysconfdir}/init.d/sshd
35
36     install -d ${D}/${sysconfdir}/sysconfig/
37     install -m 644 ${WORKDIR}/stx/sshd.sysconfig ${D}/${sysconfdir}/sysconfig/sshd
38
39     install -m 755 ${WORKDIR}/stx/sshd-keygen ${D}/${sbindir}/sshd-keygen
40     install -m644 ${WORKDIR}/stx/sshd.service ${D}/${systemd_system_unitdir}/sshd.service
41     install -m644 ${WORKDIR}/stx/sshd-keygen.service ${D}/${systemd_system_unitdir}/sshd-keygen.service
42
43     install -d ${D}/${sysconfdir}/tmpfiles.d
44     echo "d ${localstatedir}/run/sshd 0755 root root -" >> ${D}/${sysconfdir}/tmpfiles.d/sshd.conf
45
46 }
47
48 RDEPENDS_${PN} += "bash"
49 RDEPENDS_${PN}-sshd += "bash"
50
51 # allow both systemd service and sysvinit scripts are installed
52 DISTRO_FEATURES_BACKFILL_CONSIDERED_remove = "sysvinit"
53
54 USERADD_PARAM_${PN}-sshd = "-r -d /var/empty/sshd -s /sbin/nologin -g sshd -c 'Privilege-separated SSH' sshd"
55 GROUPADD_PARAM_${PN}-sshd = "-r ssh_keys; -r sshd"