Ok the script is working! Thank you Dmitry!
> On Nov 14, 2016, at 3:06 PM, Dmitry Konstantinov <barma...@barmaley.net> > wrote: > > We 'fix' it from system-wide vps.mount > The part that does the fix: > > ***** > if [[ "${OSTEMPLATE}" =~ "centos-7" && -n "${HOSTNAME}" ]]; then > echo "OVZHOSTNAME=\"${HOSTNAME}\"" > ${VE_ROOT}/etc/sysconfig/ovzhostname > if [[ ! -f ${VE_ROOT}/etc/systemd/system/ovzhostname.service ]]; then > cat << XXTAGXX > ${VE_ROOT}/etc/systemd/system/ovzhostname.service > [Unit] > Description=hostname fix for cpanel > After=network.target > Before=cpanel.service > > [Service] > Type=oneshot > ExecStart=/etc/init.d/ovzhostname > > [Install] > WantedBy=multi-user.target > XXTAGXX > fi > > if [[ ! -L > ${VE_ROOT}/etc/systemd/system/multi-user.target.wants/ovzhostname.service ]]; > then > ln -s /etc/systemd/system/ovzhostname.service \ > > ${VE_ROOT}/etc/systemd/system/multi-user.target.wants/ovzhostname.service > fi > > if [[ ! -f ${VE_ROOT}/etc/init.d/ovzhostname ]]; then > cat << XXTAGXX > ${VE_ROOT}/etc/init.d/ovzhostname > #!/bin/bash > > OVZHOSTNAME="" > > if [[ -f /etc/sysconfig/ovzhostname ]]; then > source /etc/sysconfig/ovzhostname > if [[ -n "\${OVZHOSTNAME}" ]]; then > echo "\${OVZHOSTNAME}" > /etc/hostname > hostname "\${OVZHOSTNAME}" > hostnamectl set-hostname "\${OVZHOSTNAME}" > fi > fi > XXTAGXX > chmod 0755 ${VE_ROOT}/etc/init.d/ovzhostname > fi > fi > ***** > > On Fri, 11 Nov 2016 04:33:18 +0000 > Jean-Pierre Abboud <jpabb...@gotekky.com> wrote: > >> Hello everyone, >> >> We’re facing an issue on many CentOS 7.x containers running cPanel. Clients >> are getting emails saying that the hostnames are not valid, for example it >> will show server1 instead of the fully qualified domain name >> server1.domain.com >> >> I have tried changing the hostname via cPanel or even manually but after >> rebooting it goes back to server1 >> >> The container’s openvz config does contain the appropriate HOSTNAME line >> HOSTNAME=“server1.domain.com" >> >> [root@server1 network-scripts]# cat /etc/hosts >> 127.0.0.1 localhost.localdomain localhost localhost4.localdomain4 localhost4 >> # Auto-generated hostname. Please do not remove this comment. >> 104.245.200.10 server1.domain.com localhost6 localhost6.localdomain6 >> server1 localhost.localdomain >> ::1 localhost >> >> [root@server1 network-scripts]# cat /etc/hostname >> server1 >> >> [root@server1 network-scripts]# cat /proc/sys/kernel/hostname >> server1 >> >> [root@server1 network-scripts]# cat /etc/sysconfig/network >> NETWORKING="yes" >> GATEWAYDEV="venet0" >> NETWORKING_IPV6="yes" >> IPV6_DEFAULTDEV="venet0" >> HOSTNAME=server1.domain.com >> DOMAINNAME=domain.com >> >> [root@server1 network-scripts]# cat /etc/redhat-release >> CentOS Linux release 7.2.1511 (Core) >> >> Please note that I replaced the client’s domain and IP for privacy reasons. >> >> >> Thank you! >> >> -- >> Jean-Pierre Abboud >> Account Manager / Gotekky >> 888.915.4400 / 514.316.1885 >> Email: jpabb...@gotekky.com >> >> >> _______________________________________________ >> Users mailing list >> Users@openvz.org >> https://lists.openvz.org/mailman/listinfo/users > _______________________________________________ > Users mailing list > Users@openvz.org > https://lists.openvz.org/mailman/listinfo/users _______________________________________________ Users mailing list Users@openvz.org https://lists.openvz.org/mailman/listinfo/users