|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +RHOST='r.vestacp.com' |
| 4 | +CHOST='c.vestacp.com' |
| 5 | +REPO='cmmnt' |
| 6 | +VERSION='rhel' |
| 7 | +VESTA='/usr/local/vesta' |
| 8 | +os=$(cut -f 1 -d ' ' /etc/redhat-release) |
| 9 | +release=$(grep -o "[0-9]" /etc/redhat-release |head -n1) |
| 10 | +codename="${os}_$release" |
| 11 | +vestacp="http://$CHOST/$VERSION/$release" |
| 12 | +servername=$(hostname -f) |
| 13 | + |
| 14 | + |
| 15 | +# PATH fix |
| 16 | +if [ $( grep -ic "VESTA" /etc/profile.d/vesta.sh ) -eq 0 ]; then |
| 17 | + echo "export VESTA='$VESTA'" > /etc/profile.d/vesta.sh |
| 18 | +fi |
| 19 | +if [ $( grep -ic "vesta" /root/.bash_profile ) -eq 0 ]; then |
| 20 | + echo 'PATH=$PATH:'$VESTA'/bin' >> /root/.bash_profile |
| 21 | +fi |
| 22 | + |
| 23 | + |
| 24 | +# Linking /var/log/vesta |
| 25 | +if [ ! -L "/var/log/vesta" ]; then |
| 26 | + ln -s $VESTA/log /var/log/vesta |
| 27 | +fi |
| 28 | + |
| 29 | + |
| 30 | +# Added default install "expect" to work for backup sftp |
| 31 | +yum -y install expect > /dev/null 2>&1 |
| 32 | + |
| 33 | + |
| 34 | +# Roundcube Vesta password driver - changing password_vesta_host (in config) to server hostname |
| 35 | +if [ -f "/usr/share/roundcubemail/plugins/password/config.inc.php" ]; then |
| 36 | + sed -i "s/localhost/$servername/g" /usr/share/roundcubemail/plugins/password/config.inc.php |
| 37 | +fi |
| 38 | + |
| 39 | + |
| 40 | +# Workaround for OpenVZ/Virtuozzo |
| 41 | +if [ "$release" -eq '7' ] && [ -e "/proc/vz/veinfo" ]; then |
| 42 | + if [ $( grep -ic "Vesta: workraround for networkmanager" /etc/rc.local ) -eq 0 ]; then |
| 43 | + if [ -f "/etc/nginx/nginx.conf" ] ; then |
| 44 | + echo "#Vesta: workraround for networkmanager" >> /etc/rc.local |
| 45 | + echo "sleep 3 && service nginx restart" >> /etc/rc.local |
| 46 | + fi |
| 47 | + if [ -f "/etc/httpd/conf/httpd.conf" ] ; then |
| 48 | + echo "#Vesta: workraround for networkmanager" >> /etc/rc.local |
| 49 | + echo "sleep 2 && service httpd restart" >> /etc/rc.local |
| 50 | + fi |
| 51 | + fi |
| 52 | +fi |
| 53 | + |
| 54 | + |
| 55 | +# Fix for Spamassassin user_prefs |
| 56 | +if [ -f "/etc/mail/spamassassin/local.cf" ] ; then |
| 57 | + if [ ! -d "/var/lib/spamassassin" ] ; then |
| 58 | + if [ "$release" -eq '7' ]; then |
| 59 | + groupadd -g 1001 spamd |
| 60 | + useradd -u 1001 -g spamd -s /sbin/nologin -d \ |
| 61 | + /var/lib/spamassassin spamd |
| 62 | + mkdir /var/lib/spamassassin |
| 63 | + chown spamd:spamd /var/lib/spamassassin |
| 64 | + fi |
| 65 | + fi |
| 66 | +fi |
| 67 | + |
| 68 | + |
| 69 | +# Fix for clamav: /var/run ownership and foreground option |
| 70 | +if [ -f "/etc/clamd.conf" ] ; then |
| 71 | + chown clam:clam /var/log/clamav /var/run/clamav |
| 72 | + if [ "$release" -eq '7' ]; then |
| 73 | + sed -i "s/nofork/foreground/" /usr/lib/systemd/system/clamd.service |
| 74 | + systemctl daemon-reload |
| 75 | + fi |
| 76 | +fi |
| 77 | + |
| 78 | + |
| 79 | +# Fixing empty NAT ip |
| 80 | +ip=$(ip addr|grep 'inet '|grep global|head -n1|awk '{print $2}'|cut -f1 -d/) |
| 81 | +pub_ip=$(curl -s vestacp.com/what-is-my-ip/) |
| 82 | +file="$VESTA/data/ips/$ip" |
| 83 | +if [ -f "$file" ] && [ $( grep -ic "NAT=''" $file ) -eq 1 ]; then |
| 84 | + if [ ! -z "$pub_ip" ] && [ "$pub_ip" != "$ip" ]; then |
| 85 | + v-change-sys-ip-nat $ip $pub_ip |
| 86 | + fi |
| 87 | +fi |
0 commit comments