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