upgrade-centos-v16-to-v17.sh 3.2 KB

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