pam-config: add pam_deny module for password
[pti/rtp.git] / meta-stx / recipes-core / stx-config-files / config-files_1.0.0.bb
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 DESCRIPTION = "stx-config-files"
17
18 PROTOCOL = "https"
19 BRANCH = "r/stx.3.0"
20 SRCREV = "d778e862571957ece3c404c0c37d325769772fde"
21 SRCNAME = "config-files"
22 S = "${WORKDIR}/git"
23 PV = "1.0.0"
24
25 LICENSE = "Apache-2.0"
26 LIC_FILES_CHKSUM = "\
27         file://systemd-config/files/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
28         file://audit-config/files/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
29         file://docker-config/files/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
30         file://filesystem-scripts/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
31         file://filesystem-scripts/filesystem-scripts-1.0/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
32         file://io-scheduler/centos/files/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
33         file://iptables-config/files/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
34         file://lighttpd-config/files/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
35         file://logrotate-config/files/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
36         file://mlx4-config/files/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
37         file://ntp-config/files/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
38         file://openldap-config/files/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
39         file://openvswitch-config/files/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
40         file://shadow-utils-config/files/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
41         file://sudo-config/files/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
42         file://syslog-ng-config/files/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
43         file://systemd-config/files/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
44         "
45
46 SRC_URI = " \
47         git://opendev.org/starlingx/${SRCNAME}.git;protocol=${PROTOCOL};rev=${SRCREV};branch=${BRANCH} \
48         file://openssh-config-rm-hmac-ripemd160.patch \
49         file://util-linux-pam-postlogin.patch \
50         file://syslog-ng-config-parse-err.patch \
51         file://syslog-ng-config-systemd-service.patch \
52         file://syslog-ng-conf-replace-match-with-message.patch \
53         file://lighttpd-init-script-chroot.patch \
54         file://nfsserver-remvoe-the-f-option-for-rpc.mountd.patch \
55         file://nfsserver.service-add-dependency-on-rpcbind.service.patch \
56         "
57
58 do_configure () {
59         :
60 }
61
62 do_compile () {
63         :
64 }
65
66 do_install () {
67         install -m 0755 -d ${D}/${datadir}/starlingx/config-files
68         for f in $(find ./ -name '*\.spec' | cut -d '/' -f2);
69         do 
70                 tar -c $f -f - | tar -C ${D}/${datadir}/starlingx/config-files -xf -;
71         done
72         find ${D}/${datadir}/starlingx/config-files -name centos -exec rm -rf {} +
73         chown -R root:root ${D}/${datadir}/starlingx/config-files/
74
75         # For io-scheduler-config
76         mkdir -p  ${D}/${sysconfdir}/udev/rules.d
77         install -m 644 ${S}/io-scheduler/centos/files/60-io-scheduler.rules ${D}/${sysconfdir}/udev/rules.d/60-io-scheduler.rules
78         rm -rf ${D}/${datadir}/starlingx/config-files/io-scheduler
79 }
80
81 PACKAGES ?= ""
82 PACKAGES += "audit-config"
83 PACKAGES += "centos-release-config"
84 PACKAGES += "dhclient-config"
85 PACKAGES += "dnsmasq-config"
86 PACKAGES += "docker-config"
87 PACKAGES += "initscripts-config"
88 PACKAGES += "filesystem-scripts"
89 PACKAGES += "haproxy-config"
90 PACKAGES += "ioscheduler-config"
91 PACKAGES += "iptables-config"
92 PACKAGES += "iscsi-initiator-utils-config"
93 PACKAGES += "lighttpd-config"
94 PACKAGES += "logrotate-config"
95 PACKAGES += "memcached-custom"
96 PACKAGES += "mlx4-config"
97 PACKAGES += "net-snmp-config"
98 PACKAGES += "nfs-utils-config"
99 PACKAGES += "ntp-config"
100 PACKAGES += "openldap-config"
101 PACKAGES += "openssh-config"
102 PACKAGES += "openvswitch-config"
103 PACKAGES += "pam-config"
104 PACKAGES += "rabbitmq-server-config"
105 PACKAGES += "rsync-config"
106 PACKAGES += "setup-config"
107 PACKAGES += "shadow-utils-config"
108 PACKAGES += "sudo-config"
109 PACKAGES += "syslog-ng-config"
110 PACKAGES += "systemd-config"
111 PACKAGES += "util-linux-config"
112
113 FILES_${PN} = ""
114 FILES_audit-config = "${datadir}/starlingx/config-files/audit-config/"
115 FILES_centos-release-config = "${datadir}/starlingx/config-files/centos-release-config/"
116 FILES_dhclient-config = "${datadir}/starlingx/config-files/dhcp-config/"
117 FILES_dnsmasq-config = "${datadir}/starlingx/config-files/dnsmasq-config/"
118 FILES_docker-config = "${datadir}/starlingx/config-files/docker-config/"
119 FILES_initscripts-config = "${datadir}/starlingx/config-files/initscripts-config/"
120 FILES_filesystem-scripts= "${datadir}/starlingx/config-files/filesystem-scripts/"
121 FILES_haproxy-config= "${datadir}/starlingx/config-files/haproxy-config/"
122 FILES_ioscheduler-config= "${sysconfdir}/udev/rules.d/60-io-scheduler.rules"
123 FILES_iptables-config= "${datadir}/starlingx/config-files/iptables-config/"
124 FILES_iscsi-initiator-utils-config = "${datadir}/starlingx/config-files/iscsi-initiator-utils-config/"
125 FILES_lighttpd-config= "${datadir}/starlingx/config-files/lighttpd-config/"
126 FILES_logrotate-config= "${datadir}/starlingx/config-files/logrotate-config/"
127 FILES_memcached-custom = "${datadir}/starlingx/config-files/memcached-custom/"
128 FILES_mlx4-config= "${datadir}/starlingx/config-files/mlx4-config/"
129 FILES_net-snmp-config= "${datadir}/starlingx/config-files/net-snmp-config/"
130 FILES_nfs-utils-config= "${datadir}/starlingx/config-files/nfs-utils-config/"
131 FILES_ntp-config= "${datadir}/starlingx/config-files/ntp-config/"
132 FILES_openldap-config= "${datadir}/starlingx/config-files/openldap-config/"
133 FILES_openssh-config= "${datadir}/starlingx/config-files/openssh-config/"
134 FILES_openvswitch-config= "${datadir}/starlingx/config-files/openvswitch-config/"
135 FILES_pam-config= "${datadir}/starlingx/config-files/pam-config/"
136 FILES_rabbitmq-server-config= "${datadir}/starlingx/config-files/rabbitmq-server-config/"
137 FILES_rsync-config= "${datadir}/starlingx/config-files/rsync-config/"
138 FILES_setup-config= "${datadir}/starlingx/config-files/setup-config/"
139 FILES_shadow-utils-config= "${datadir}/starlingx/config-files/shadow-utils-config/"
140 FILES_sudo-config= "${datadir}/starlingx/config-files/sudo-config/"
141 FILES_syslog-ng-config= "${datadir}/starlingx/config-files/syslog-ng-config/"
142 FILES_systemd-config= "${datadir}/starlingx/config-files/systemd-config/"
143 FILES_util-linux-config= "${datadir}/starlingx/config-files/util-linux-config/"
144
145 RDEPENDS_audit-config += " \
146         audit \
147         auditd \
148         audit-python \
149         "
150 RDEPENDS_dhclient-config += "dhcp-client"
151 RDEPENDS_dnsmasq-config += "dnsmasq"
152 RDEPENDS_docker-config += "docker-ce logrotate "
153 RDEPENDS_initscripts-config += "initscripts"
154 RDEPENDS_filesystem-scripts += ""
155 RDEPENDS_haproxy-config += "haproxy"
156 RDEPENDS_ioscheduler-config += ""
157 RDEPENDS_iptables-config += "iptables"
158 RDEPENDS_iscsi-initiator-utils-config += " iscsi-initiator-utils"
159 RDEPENDS_lighttpd-config += " \
160         lighttpd \
161         lighttpd-module-proxy \
162         lighttpd-module-setenv \
163         "
164 RDEPENDS_logrotate-config += " logrotate cronie"
165 RDEPENDS_memcached-custom += "memcached"
166 RDEPENDS_mlx4-config += ""
167 RDEPENDS_net-snmp-config += " \
168         net-snmp \
169         net-snmp-server-snmpd \
170         net-snmp-server-snmptrapd \
171         "
172 RDEPENDS_nfs-utils-config += " nfs-utils"
173 RDEPENDS_ntp-config += " ntp"
174 RDEPENDS_openldap-config += " \
175         openldap \
176         "
177 RRECOMMENDS_openldap-config += " \
178         openldap-slapd \
179         openldap-backend-shell \
180         openldap-backend-passwd \
181         openldap-backend-null \
182         openldap-backend-monitor \
183         openldap-backend-meta \
184         openldap-backend-ldap \
185         openldap-backend-dnssrv \
186         openldap-staticdev \
187         openldap-locale \
188         openldap-overlay-proxycache \
189         openldap-slapd \
190         openldap-slurpd \
191         openldap-bin \
192         "
193
194 RDEPENDS_openssh-config += " openssh"
195 RDEPENDS_openvswitch-config += " openvswitch"
196 RDEPENDS_pam-config += " \
197         libpam-runtime \
198         nss-pam-ldapd \
199         libpwquality \
200         pam-plugin-access \
201         pam-plugin-cracklib \
202         pam-plugin-debug \
203         pam-plugin-deny \
204         pam-plugin-echo \
205         pam-plugin-env \
206         pam-plugin-exec \
207         pam-plugin-faildelay \
208         pam-plugin-filter \
209         pam-plugin-ftp \
210         pam-plugin-group \
211         pam-plugin-issue \
212         pam-plugin-keyinit \
213         pam-plugin-lastlog \
214         pam-plugin-limits \
215         pam-plugin-listfile \
216         pam-plugin-localuser \
217         pam-plugin-loginuid \
218         pam-plugin-mail \
219         pam-plugin-mkhomedir \
220         pam-plugin-motd \
221         pam-plugin-namespace \
222         pam-plugin-nologin \
223         pam-plugin-permit \
224         pam-plugin-pwhistory \
225         pam-plugin-rhosts \
226         pam-plugin-rootok \
227         pam-plugin-securetty \
228         pam-plugin-shells \
229         pam-plugin-stress \
230         pam-plugin-succeed-if \
231         pam-plugin-tally \
232         pam-plugin-tally2 \
233         pam-plugin-time \
234         pam-plugin-timestamp \
235         pam-plugin-umask \
236         pam-plugin-unix \
237         pam-plugin-warn \
238         pam-plugin-wheel \
239         pam-plugin-xauth \
240         "
241 RDEPENDS_rabbitmq-server-config += " rabbitmq-server"
242 RDEPENDS_rsync-config += " rsync"
243 RDEPENDS_setup-config += ""
244 RDEPENDS_shadow-utils-config += " shadow"
245 RDEPENDS_sudo-config += " sudo"
246 RDEPENDS_syslog-ng-config += " syslog-ng"
247 RDEPENDS_systemd-config += " systemd"
248 RDEPENDS_util-linux-config += " util-linux"
249
250 pkg_postinst_ontarget_audit-config() {
251         cp -f ${datadir}/starlingx/config-files/audit-config/files/syslog.conf ${sysconfdir}/audisp/plugins.d/syslog.conf
252         chmod 640 ${sysconfdir}/audisp/plugins.d/syslog.conf
253 }
254
255 pkg_postinst_centos-release-config() {
256         sed 's/@PLATFORM_RELEASE@/${ORAN_REL}/' $D${datadir}/starlingx/config-files/centos-release-config/files/issue >> $D${sysconfdir}/issue
257         sed 's/@PLATFORM_RELEASE@/${ORAN_REL}/' $D${datadir}/starlingx/config-files/centos-release-config/files/issue.net >> $D${sysconfdir}/issue.net
258         chmod 644 $D${sysconfdir}/issue
259         chmod 644 $D${sysconfdir}/issue.net
260 }
261
262 pkg_postinst_ontarget_dhclient-config() {
263         SRCPATH=${datadir}/starlingx/config-files/dhcp-config/files
264         install -m 0755 -p ${SRCPATH}/dhclient-enter-hooks ${sysconfdir}/dhcp/dhclient-enter-hooks
265         install -m 0755 -p ${SRCPATH}/dhclient.conf ${sysconfdir}/dhcp/dhclient/dhclient.conf
266         ln -fs ${sysconfdir}/dhcp/dhclient-enter-hooks ${sysconfdir}/dhclient-enter-hooks
267 }
268         
269 pkg_postinst_ontarget_dnsmasq-config() {
270         install -m 755 ${datadir}/starlingx/config-files/dnsmasq-config/files/init ${sysconfdir}/init.d/dnsmasq
271 }
272
273 pkg_postinst_ontarget_docker-config() {
274         SRCPATH=${datadir}/starlingx/config-files/docker-config/files
275         install -d -m 0755 ${sysconfdir}/systemd/system/docker.service.d
276
277         install -D -m 644 ${SRCPATH}/docker-pmond.conf ${sysconfdir}/pmon.d/docker.conf
278         install -D -m 644 ${SRCPATH}/docker-stx-override.conf \
279                         ${sysconfdir}/systemd/system/docker.service.d/docker-stx-override.conf 
280         install -D -m 644 ${SRCPATH}/docker.logrotate ${sysconfdir}/logrotate.d/docker.logrotate
281 }
282
283 pkg_postinst_ontarget_filesystem-scripts() {
284         SRCPATH=${datadir}/starlingx/config-files/filesystem-scripts/filesystem-scripts-1.0
285         install -D -m 755 ${SRCPATH}/uexportfs ${sysconfdir}/init.d/uexportfs
286
287         install -d -m 0755 /usr/lib/ocf/resource.d/platform/
288         install -D -m 755 ${SRCPATH}/nfsserver-mgmt /usr/lib/ocf/resource.d/platform/nfsserver-mgmt
289
290         install -p -D -m 755 ${SRCPATH}/nfs-mount ${bindir}/nfs-mount
291         install -D -m 755 ${SRCPATH}/uexportfs.service ${systemd_system_unitdir}/uexportfs.service
292
293         systemctl enable uexportfs.service
294 }
295
296
297 pkg_postinst_ontarget_haproxy-config() {
298
299         install -d -m 755 ${sysconfdir}/haproxy/errors/
300         install -m 755 ${datadir}/starlingx/config-files/haproxy-config/files/503.http ${sysconfdir}/haproxy/errors/503.http
301
302         install -m 644 ${datadir}/starlingx/config-files/haproxy-config/files/haproxy.service ${sysconfdir}/systemd/system/
303         install -p -D -m 0755 ${datadir}/starlingx/config-files/haproxy-config/files/haproxy.sh ${sysconfdir}/init.d/haproxy
304
305         /bin/systemctl disable haproxy.service
306         if test -s ${sysconfdir}/logrotate.d/haproxy ; then
307             echo '#See /etc/logrotate.d/syslog for haproxy rules' > ${sysconfdir}/logrotate.d/haproxy
308         fi
309 }
310
311 pkg_postinst_ontarget_initscripts-config() {
312         install -d  -m 755 ${sysconfdir}/sysconfig
313         install -d  -m 755 ${sysconfdir}/init.d
314         install -d  -m 755 ${systemd_system_unitdir}
315
316         SRCPATH=${datadir}/starlingx/config-files/initscripts-config/files
317         install -m  644 ${SRCPATH}/sysctl.conf ${datadir}/starlingx/stx.sysctl.conf
318         install -m  644 ${SRCPATH}/sysconfig-network.conf ${sysconfdir}/sysconfig/network
319         install -m  755 ${SRCPATH}/mountnfs.sh ${sysconfdir}/init.d/mountnfs
320         install -m  644 ${SRCPATH}/mountnfs.service ${systemd_system_unitdir}/mountnfs.service
321
322
323         cp -f ${datadir}/starlingx/stx.sysctl.conf ${sysconfdir}/sysctl.conf
324         chmod 644 ${sysconfdir}/sysctl.conf
325 }
326
327 pkg_postinst_ontarget_iscsi-initiator-utils-config() {
328 #       %description
329 #       package StarlingX configuration files of iscsi-initiator-utils to system folder.
330
331 #       install -d  ${libdir}/tmpfiles.d
332 #       install -d  ${sysconfdir}/systemd/system
333 #       install -d  ${datadir}/starlingx
334
335         SRCPATH=${datadir}/starlingx/config-files/iscsi-initiator-utils-config/files
336         tmpfilesdir=${libdir}/tmpfiles.d
337
338         install -m 0644 ${SRCPATH}/iscsi-cache.volatiles   ${tmpfilesdir}/iscsi-cache.conf
339         install -m 0644 ${SRCPATH}/iscsi-shutdown.service  ${sysconfdir}/systemd/system
340         install -m 0644 ${SRCPATH}/iscsid.conf             ${datadir}/starlingx/stx.iscsid.conf
341
342         cp -f ${datadir}/starlingx/stx.iscsid.conf ${sysconfdir}/iscsi/iscsid.conf
343         chmod 0750 ${sysconfdir}/iscsi
344         chmod 0640 ${sysconfdir}/iscsi/iscsid.conf
345         
346         /bin/systemctl disable iscsi-shutdown.service
347 }
348
349 pkg_postinst_ontarget_lighttpd-config() {
350 #       %description
351 #       StarlingX lighttpd configuration file
352
353         CONFDIR=${sysconfdir}/lighttpd
354         ROOTDIR=/www
355         SRCPATH=${datadir}/starlingx/config-files/lighttpd-config/files
356
357         install -d -m 1777 ${ROOTDIR}/tmp
358         install -d ${CONFDIR}/ssl
359         install -d ${ROOTDIR}/pages/dav
360         install -m640 ${SRCPATH}/lighttpd.conf          ${datadir}/starlingx/lighttpd.conf
361         install -m755 ${SRCPATH}/lighttpd.init          ${datadir}/starlingx/lighttpd.init
362         install -m644 ${SRCPATH}/lighttpd-inc.conf      ${CONFDIR}/lighttpd-inc.conf
363         install -m644 ${SRCPATH}/index.html.lighttpd    ${ROOTDIR}/pages/index.html
364
365         install -d ${sysconfdir}/logrotate.d
366         install -m644 ${SRCPATH}/lighttpd.logrotate     ${datadir}/starlingx/lighttpd.logrotate
367         chmod 02770 ${sysconfdir}/lighttpd
368
369         cp --preserve=xattr -f ${datadir}/starlingx/lighttpd.conf  ${sysconfdir}/lighttpd/lighttpd.conf
370         chmod 640 ${sysconfdir}/lighttpd/lighttpd.conf
371         cp --preserve=xattr -f ${datadir}/starlingx/lighttpd.logrotate ${sysconfdir}/logrotate.d/lighttpd
372         chmod 644 ${sysconfdir}/logrotate.d/lighttpd
373
374         # /etc/rc.d/init.d/lighttpd is not a config file, so replace it here if it doesn't match
375         cp --preserve=xattr -f ${datadir}/starlingx/lighttpd.init ${sysconfdir}/rc.d/init.d/lighttpd
376         cp --preserve=xattr -f ${datadir}/starlingx/lighttpd.init ${sysconfdir}/init.d/lighttpd
377         chmod 755 ${sysconfdir}/rc.d/init.d/lighttpd
378         chmod 755 ${sysconfdir}/init.d/lighttpd
379 }
380
381 pkg_postinst_ontarget_logrotate-config() {
382 #       %description
383 #       StarlingX logrotate configuration file
384
385         SRCPATH=${datadir}/starlingx/config-files/logrotate-config/files
386
387         install -m 644 ${SRCPATH}/logrotate-cron.d ${sysconfdir}/cron.d/logrotate
388         install -m 644 ${SRCPATH}/logrotate.conf ${datadir}/starlingx/logrotate.conf
389
390         cp -f ${datadir}/starlingx/logrotate.conf ${sysconfdir}/logrotate.conf 
391         chmod 644 ${sysconfdir}/logrotate.conf
392         mv ${sysconfdir}/cron.daily/logrotate ${sysconfdir}/logrotate.cron
393         chmod 700 ${sysconfdir}/logrotate.cron
394 }
395
396
397 pkg_postinst_ontarget_memcached-custom() {
398 #       Summary: package memcached service files to system folder.
399
400         SRCPATH=${datadir}/starlingx/config-files/memcached-custom/files
401         install -m 644 -p ${SRCPATH}/memcached.service ${sysconfdir}/systemd/system/memcached.service
402 }
403
404
405 pkg_postinst_ontarget_mlx4-config() {
406 #       %description
407 #       Wind River Mellanox port-type configuration scripts
408         SRCPATH=${datadir}/starlingx/config-files/mlx4-config/files
409
410 #       /bin/systemctl disable mlx4-config.service >/dev/null 2>&1
411
412         install -m 755 ${SRCPATH}/mlx4-configure.sh     ${sysconfdir}/init.d/
413         install -m 644 ${SRCPATH}/mlx4-config.service   ${systemd_system_unitdir}/
414         install -m 555 ${SRCPATH}/mlx4_core_goenabled.sh ${sysconfdir}/goenabled.d/
415         install -m 755 ${SRCPATH}/mlx4_core_config.sh   ${bindir}/
416
417         /bin/systemctl enable mlx4-config.service >/dev/null 2>&1
418 }
419
420
421 pkg_postinst_ontarget_net-snmp-config() {
422 #       %description
423 #       package StarlingX configuration files of net-snmp to system folder.
424
425         SRCPATH=${datadir}/starlingx/config-files/net-snmp-config/files
426
427         install -d ${datadir}/snmp
428
429         install -m 644 ${SRCPATH}/stx.snmpd.conf    ${datadir}/starlingx/stx.snmpd.conf
430         install -m 755 ${SRCPATH}/stx.snmpd         ${sysconfdir}/rc.d/init.d/snmpd
431         install -m 755 ${SRCPATH}/stx.snmpd         ${sysconfdir}/init.d/snmpd
432         install -m 660 ${SRCPATH}/stx.snmp.conf     ${datadir}/snmp/snmp.conf
433         install -m 644 ${SRCPATH}/snmpd.service     ${sysconfdir}/systemd/system/snmpd.service
434         
435         
436         cp -f ${datadir}/starlingx/stx.snmpd.conf   ${sysconfdir}/snmp/snmpd.conf
437         chmod 640 ${sysconfdir}/snmp/snmpd.conf
438         chmod 640 ${sysconfdir}/snmp/snmptrapd.conf
439         
440         /bin/systemctl disable snmpd.service
441 }
442
443
444 pkg_postinst_nfs-utils-config() {
445 #       %description
446 #       package customized configuration and service files of nfs-utils to system folder.
447
448
449         SRCPATH=$D${datadir}/starlingx/config-files/nfs-utils-config/files
450         
451
452         install -m 755 -p -D ${SRCPATH}/nfscommon               $D${sysconfdir}/init.d
453         install -m 644 -p -D ${SRCPATH}/nfscommon.service       $D${systemd_system_unitdir}/
454         install -m 755 -p -D ${SRCPATH}/nfsserver               $D${sysconfdir}/init.d
455         install -m 644 -p -D ${SRCPATH}/nfsserver.service       $D${systemd_system_unitdir}
456         install -m 644 -p -D ${SRCPATH}/nfsmount.conf           $D${datadir}/starlingx/stx.nfsmount.conf
457         
458         cp -f $D${datadir}/starlingx/stx.nfsmount.conf $D${sysconfdir}/nfsmount.conf
459         chmod 644 $D${sysconfdir}/nfsmount.conf
460
461         # enable nfs services by default
462         OPTS=""
463         if [ -n "$D" ]; then
464                 OPTS="--root=$D"
465         fi
466         if [ -z "$D" ]; then
467                 systemctl daemon-reload
468         fi
469
470         systemctl $OPTS enable nfscommon.service
471         systemctl $OPTS enable nfsserver.service
472
473         if [ -z "$D" ]; then
474                 systemctl --no-block restart nfscommon.service
475                 systemctl --no-block restart nfsserver.service
476         fi
477 }
478
479 pkg_postinst_ontarget_ntp-config() {
480 #       %description
481 #       StarlingX ntp configuration file
482
483         SRCPATH=${datadir}/starlingx/config-files/ntp-config/files
484         install -D -m644 ${SRCPATH}/ntpd.sysconfig ${datadir}/starlingx/ntpd.sysconfig
485         install -D -m644 ${SRCPATH}/ntp.conf ${datadir}/starlingx/ntp.conf
486
487         cp -f ${datadir}/starlingx/ntpd.sysconfig ${sysconfdir}/sysconfig/ntpd
488         cp -f ${datadir}/starlingx/ntp.conf ${sysconfdir}/ntp.conf
489         chmod 644 ${sysconfdir}/sysconfig/ntpd
490         chmod 644 ${sysconfdir}/ntp.conf
491 }
492
493
494 pkg_postinst_ontarget_openldap-config() {
495 #       $description
496 #       StarlingX openldap configuration file
497
498         SRCPATH=${datadir}/starlingx/config-files/openldap-config/files
499
500         install -m 755 ${SRCPATH}/initscript ${sysconfdir}/init.d/openldap
501         install -m 600 ${SRCPATH}/slapd.conf ${sysconfdir}/openldap/slapd.conf
502
503         install -m 600 ${SRCPATH}/initial_config.ldif ${sysconfdir}/openldap/initial_config.ldif
504
505         install -m 644 ${SRCPATH}/slapd.service ${sysconfdir}/systemd/system/slapd.service
506         install -m 644 ${SRCPATH}/slapd.sysconfig ${datadir}/starlingx/slapd.sysconfig 
507
508         sed -i -e 's|/var/run|/run|' ${sysconfdir}/systemd/system/slapd.service
509         
510         cp -f ${datadir}/starlingx/slapd.sysconfig ${sysconfdir}/sysconfig/slapd
511         chmod 644 ${systemd_system_unitdir}/slapd
512 }
513
514 pkg_postinst_openssh-config() {
515 #       %description
516 #       package StarlingX configuration files of openssh to system folder.
517
518
519         SRCPATH=$D${datadir}/starlingx/config-files/openssh-config/files
520
521         install -m 644 ${SRCPATH}/sshd.service  $D${sysconfdir}/systemd/system/sshd.service
522         install -m 644 ${SRCPATH}/ssh_config    $D${datadir}/starlingx/ssh_config
523         install -m 600 ${SRCPATH}/sshd_config   $D${datadir}/starlingx/sshd_config
524
525         # remove the unsupported and deprecated options
526         sed -i -e 's/^\(GSSAPIAuthentication.*\)/#\1/' \
527                -e 's/^\(GSSAPICleanupCredentials.*\)/#\1/' \
528                -e 's/^\(UsePrivilegeSeparation.*\)/#\1/' \
529                $D${datadir}/starlingx/sshd_config
530
531         sed -i -e 's/\(GSSAPIAuthentication yes\)/#\1/' $D${datadir}/starlingx/ssh_config
532         
533         cp -f $D${datadir}/starlingx/ssh_config  $D${sysconfdir}/ssh/ssh_config
534         cp -f $D${datadir}/starlingx/sshd_config $D${sysconfdir}/ssh/sshd_config
535
536         # enable sshd service by default
537         OPTS=""
538         if [ -n "$D" ]; then
539                 OPTS="--root=$D"
540         fi
541         if [ -z "$D" ]; then
542                 systemctl daemon-reload
543         fi
544
545         systemctl $OPTS enable sshd.service
546
547         if [ -z "$D" ]; then
548                 systemctl --no-block restart sshd.service
549         fi
550
551 }
552
553 pkg_postinst_ontarget_openvswitch-config() {
554 #       %description
555 #       StarlingX openvswitch configuration file
556
557         SRCPATH=${datadir}/starlingx/config-files/openvswitch-config/files
558
559         install -m 0644 ${SRCPATH}/ovsdb-server.pmon.conf ${sysconfdir}/openvswitch/ovsdb-server.pmon.conf
560         install -m 0644 ${SRCPATH}/ovs-vswitchd.pmon.conf ${sysconfdir}/openvswitch/ovs-vswitchd.pmon.conf
561         install -m 0640 ${SRCPATH}/etc_logrotate.d_openvswitch ${datadir}/starlingx/etc_logrotate.d_openvswitch
562         
563         cp -f ${datadir}/starlingx/etc_logrotate.d_openvswitch ${sysconfdir}/logrotate.d/openvswitch
564         chmod 644 ${sysconfdir}/logrotate.d/openvswitch
565 }
566
567 pkg_postinst_ontarget_pam-config() {
568 #       %description
569 #       package StarlingX configuration files of pam to system folder.
570
571         SRCPATH=${datadir}/starlingx/config-files/pam-config/files
572
573         install  -m 644 ${SRCPATH}/sshd.pam        ${datadir}/starlingx/sshd.pam
574         install  -m 644 ${SRCPATH}/common-account  ${sysconfdir}/pam.d/common-account
575         install  -m 644 ${SRCPATH}/common-auth     ${sysconfdir}/pam.d/common-auth
576         install  -m 644 ${SRCPATH}/common-password ${sysconfdir}/pam.d/common-password
577         install  -m 644 ${SRCPATH}/common-session  ${sysconfdir}/pam.d/common-session
578         install  -m 644 ${SRCPATH}/common-session-noninteractive ${sysconfdir}/pam.d/common-session-noninteractive
579         install  -m 644 ${SRCPATH}/system-auth.pamd ${datadir}/starlingx/stx.system-auth
580         
581         cp -f ${datadir}/starlingx/stx.system-auth ${sysconfdir}/pam.d/system-auth
582         cp -f ${datadir}/starlingx/sshd.pam    ${sysconfdir}/pam.d/sshd
583
584         sed -i -e '/password .*pam_ldap.so/,/session .*revoke/ s/^$/password required pam_deny.so\n/g' \
585                 ${sysconfdir}/pam.d/system-auth
586 }
587
588 pkg_postinst_ontarget_rabbitmq-server-config() {
589 #       %description
590 #       package StarlingX configuration files of rabbitmq-server to system folder.
591
592         SRCPATH=${datadir}/starlingx/config-files/rabbitmq-server-config/files
593
594         install -d ${libdir}/ocf/resource.d/rabbitmq
595         install -m 0755 ${SRCPATH}/rabbitmq-server.ocf              ${libdir}/ocf/resource.d/rabbitmq/stx.rabbitmq-server
596         install -m 0644 ${SRCPATH}/rabbitmq-server.service.example  ${sysconfdir}/systemd/system/rabbitmq-server.service
597         install -m 0644 ${SRCPATH}/rabbitmq-server.logrotate        ${datadir}/starlingx/stx.rabbitmq-server.logrotate
598
599         sed -i -e 's/notify/simple/' ${sysconfdir}/systemd/system/rabbitmq-server.service
600
601         cp ${datadir}/starlingx/stx.rabbitmq-server.logrotate ${sysconfdir}/logrotate.d/rabbitmq-server
602 }
603
604 pkg_postinst_ontarget_rsync-config() {
605 #       %description
606 #       package StarlingX configuration files of rsync to system folder.
607
608         SRCPATH=${datadir}/starlingx/config-files/rsync-config/files
609
610         install -m 644 ${SRCPATH}/rsyncd.conf  ${datadir}/starlingx/stx.rsyncd.conf
611         
612         cp -f ${datadir}/starlingx/stx.rsyncd.conf  ${sysconfdir}/rsyncd.conf
613 }
614
615 pkg_postinst_ontarget_setup-config() {
616 #       %description
617 #       package StarlingX configuration files of setup to system folder.
618
619         SRCPATH=${datadir}/starlingx/config-files/setup-config/files
620
621         install -m 644 ${SRCPATH}/motd          ${datadir}/starlingx/stx.motd
622         install -m 644 ${SRCPATH}/prompt.sh     ${sysconfdir}/profile.d/prompt.sh
623         install -m 644 ${SRCPATH}/custom.sh     ${sysconfdir}/profile.d/custom.sh
624
625         cp -f ${datadir}/starlingx/stx.motd    ${sysconfdir}/motd
626         chmod 600   ${sysconfdir}/{exports,fstab}
627 }
628
629 pkg_postinst_ontarget_shadow-utils-config() {
630 #       %description
631 #       StarlingX shadow-utils configuration file
632
633         SRCPATH=${datadir}/starlingx/config-files/shadow-utils-config/files
634
635         install -D -m644 ${SRCPATH}/login.defs ${datadir}/starlingx/login.defs
636         install -D -m644 ${SRCPATH}/clear_shadow_locks.service  ${systemd_system_unitdir}/clear_shadow_locks.service
637
638         cp -f ${datadir}/starlingx/login.defs ${sysconfdir}/login.defs
639         chmod 644 ${sysconfdir}/login.defs
640         /bin/systemctl preset clear_shadow_locks.service
641 }
642
643 pkg_postinst_ontarget_sudo-config() {
644 #       %description
645 #       StarlingX sudo configuration file
646
647         SYSADMIN_P="4SuW8cnXFyxsk"
648         SRCPATH=${datadir}/starlingx/config-files/sudo-config/files
649
650         install -m 440 ${SRCPATH}/sysadmin.sudo  ${sysconfdir}/sudoers.d/sysadmin
651
652         getent group sys_protected >/dev/null || groupadd -f -g 345 sys_protected
653         getent passwd sysadmin > /dev/null || \
654                 useradd -m -g sys_protected -G root  -d /home/sysadmin -p ${SYSADMIN_P} -s /bin/sh sysadmin 2> /dev/null || :
655 }
656
657 pkg_postinst_syslog-ng-config() {
658 #       %description
659 #       StarlingX syslog-ng configuration file
660
661         SRCPATH=$D${datadir}/starlingx/config-files/syslog-ng-config/files
662
663         install -D -m644 ${SRCPATH}/syslog-ng.conf $D${datadir}/starlingx/syslog-ng.conf
664
665         # Fix the config version to avoid warning
666         sed -i -e 's/\(@version: \).*/\1 3.19/' $D${datadir}/starlingx/syslog-ng.conf
667
668         # Workaround: comment out the udp source to aviod the service fail to start at boot time
669         sed -i -e 's/\(.*s_udp.*\)/#\1/' $D${datadir}/starlingx/syslog-ng.conf
670
671         install -D -m644 ${SRCPATH}/syslog-ng.logrotate $D${datadir}/starlingx/syslog-ng.logrotate
672         install -D -m644 ${SRCPATH}/remotelogging.conf $D${sysconfdir}/syslog-ng/remotelogging.conf
673         install -D -m700 ${SRCPATH}/fm_event_syslogger $D${sbindir}/fm_event_syslogger
674         install -D -m644 ${SRCPATH}/syslog-ng.service $D${datadir}/starlingx/syslog-ng.service
675
676         cp -f $D${datadir}/starlingx/syslog-ng.conf $D${sysconfdir}/syslog-ng/syslog-ng.conf
677         chmod 644 $D${sysconfdir}/syslog-ng/syslog-ng.conf
678         cp -f $D${datadir}/starlingx/syslog-ng.logrotate $D${sysconfdir}/logrotate.d/syslog
679         chmod 644 $D${sysconfdir}/logrotate.d/syslog
680         cp -f $D${datadir}/starlingx/syslog-ng.service $D${systemd_system_unitdir}/syslog-ng.service
681         chmod 644 $D${systemd_system_unitdir}/syslog-ng.service
682
683         # enable syslog-ng service by default
684         OPTS=""
685         if [ -n "$D" ]; then
686                 OPTS="--root=$D"
687         fi
688         if [ -z "$D" ]; then
689                 systemctl daemon-reload
690         fi
691
692         systemctl $OPTS enable syslog-ng.service
693
694         if [ -z "$D" ]; then
695                 systemctl --no-block restart syslog-ng.service
696         fi
697 }
698
699 pkg_postinst_ontarget_systemd-config() {
700 #       %description
701 #       StarlingX systemd configuration file
702
703         SRCPATH=${datadir}/starlingx/config-files/systemd-config/files
704
705         install -m644 ${SRCPATH}/60-persistent-storage.rules ${sysconfdir}/udev/rules.d/60-persistent-storage.rules
706         install -m644 ${SRCPATH}/journald.conf ${datadir}/starlingx/journald.conf
707         install -m644 ${SRCPATH}/systemd.conf.tmpfiles.d ${sysconfdir}/tmpfiles.d/systemd.conf
708         install -m644 ${SRCPATH}/tmp.conf.tmpfiles.d ${sysconfdir}/tmpfiles.d/tmp.conf
709         install -m644 ${SRCPATH}/tmp.mount ${sysconfdir}/systemd/system/tmp.mount
710
711         cp -f ${datadir}/starlingx/journald.conf ${sysconfdir}/systemd/journald.conf
712         chmod 644 ${sysconfdir}/systemd/journald.conf
713 }
714
715 pkg_postinst_ontarget_util-linux-config() {
716 #       %description
717 #       package StarlingX configuration files of util-linux to system folder.
718
719         SRCPATH=${datadir}/starlingx/config-files/util-linux-config/files
720
721         install -m 644 ${SRCPATH}/stx.su     ${datadir}/starlingx/stx.su
722         install -m 644 ${SRCPATH}/stx.login  ${datadir}/starlingx/stx.login
723         install -m 644 ${SRCPATH}/stx.postlogin ${datadir}/starlingx/stx.postlogin
724
725         cp -f ${datadir}/starlingx/stx.su ${sysconfdir}/pam.d/su
726         cp -f ${datadir}/starlingx/stx.login  ${sysconfdir}/pam.d/login
727         cp -f ${datadir}/starlingx/stx.postlogin  ${sysconfdir}/pam.d/postlogin
728
729 }
730
731 pkg_postinst_ontarget_ioscheduler-config() {
732 #       %description
733 #       CGCS io scheduler configuration and tuning.
734
735         /bin/udevadm control --reload-rules
736         /bin/udevadm trigger --type=devices --subsystem-match=block
737 }
738
739 pkg_postinst_ontarget_iptables-config() {
740 #       %description
741 #       StarlingX iptables configuration file
742
743         SRCPATH=${datadir}/starlingx/config-files/iptables-config/files
744         
745         install -m 600 ${SRCPATH}/iptables.rules ${datadir}/starlingx/iptables.rules
746         install -m 600 ${SRCPATH}/ip6tables.rules ${datadir}/starlingx/ip6tables.rules 
747         
748         cp -f S{datadir}/starlingx/iptables.rules ${sysconfdir}/sysconfig/iptables
749         chmod 600 ${sysconfdir}/sysconfig/iptables
750         cp -f ${datadir}/starlingx/ip6tables.rules ${sysconfdir}/sysconfig/ip6tables
751         chmod 600 ${sysconfdir}/sysconfig/ip6tables
752         /bin/systemctl enable iptables.service ip6tables.service >/dev/null 2>&1
753 }