HEX
Server: CentOS WebPanel: Protected by Mod Security
System: Linux sites.annaiservers.com 3.10.0-1160.118.1.el7.x86_64 #1 SMP Wed Apr 24 16:01:50 UTC 2024 x86_64
User: freeval (1012)
PHP: 8.1.10
Disabled: NONE
Upload Files
File: //scripts/hostname_ssl_restart_services
#!/bin/bash

# CWP reload script used only in case of the hostname ssl renewal

/usr/sbin/service httpd reload
/usr/sbin/service cwpsrv reload
/usr/sbin/service postfix reload
/usr/sbin/service dovecot reload

# check for nginx
if [ -e "/etc/nginx/conf.d/" ];then
	/usr/sbin/service nginx reload
fi

BUNDLETIME=`/usr/bin/stat /etc/pki/tls/certs/hostname.bundle -L|grep ^Modify|awk {'print $2'}`
PEMTIME=`/usr/bin/stat /etc/pki/tls/private/hostname.pem -L|grep ^Modify|awk {'print $2'}`
CURRENTTIME=`date +"%Y-%m-%d %H:%M:%S"`

if [ "$BUNDLETIME" != "$PEMTIME" ];then
	if [ -e "/etc/pki/tls/certs/hostname.bundle" ];then
		if [ -e "/etc/pki/tls/private/hostname.key" ];then
			cat /etc/pki/tls/private/hostname.key > /etc/pki/tls/private/hostname.pem
			cat /etc/pki/tls/certs/hostname.bundle >> /etc/pki/tls/private/hostname.pem
			chmod 600 /etc/pki/tls/private/hostname.key
			chmod 600 /etc/pki/tls/private/hostname.pem
			touch -m --date="$BUNDLETIME" /etc/pki/tls/private/hostname.pem
			/usr/sbin/service pure-ftpd restart
		fi
	fi
fi

echo "$CURRENTTIME Running script: /scripts/hostname_ssl_restart_services" >> /var/log/cwp/services_action.log