upgrade-debian-v16-to-v17.sh 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #!/bin/bash
  2. CHOST='c.vestacp.com'
  3. VERSION='debian'
  4. VESTA='/usr/local/vesta'
  5. os='debian'
  6. release=$(cat /etc/debian_version|grep -o [0-9]|head -n1)
  7. codename="$(cat /etc/os-release |grep VERSION= |cut -f 2 -d \(|cut -f 1 -d \))"
  8. vestacp="http://$CHOST/$VERSION/$release"
  9. servername=$(hostname -f)
  10. apt-get update > /dev/null 2>&1
  11. # PATH fix
  12. if [ ! -f "/etc/profile.d/vesta.sh" ]; then
  13. echo "export VESTA='$VESTA'" > /etc/profile.d/vesta.sh
  14. fi
  15. if [ $( grep -ic "vesta" /root/.bash_profile ) -eq 0 ]; then
  16. echo 'PATH=$PATH:'$VESTA'/bin' >> /root/.bash_profile
  17. fi
  18. # Linking /var/log/vesta
  19. if [ ! -L "/var/log/vesta" ]; then
  20. ln -s $VESTA/log /var/log/vesta
  21. fi
  22. if [ -f "/etc/roundcube/plugins/password/config.inc.php" ]; then
  23. # Roundcube Vesta password driver - changing password_vesta_host (in config) to server hostname
  24. sed -i "s/localhost/$servername/g" /etc/roundcube/plugins/password/config.inc.php
  25. # Roundcube log permission fix
  26. if [ ! -d "/var/log/roundcube" ]; then
  27. mkdir /var/log/roundcube
  28. fi
  29. chown admin:admin /var/log/roundcube
  30. fi
  31. # Added default install "expect" to work for backup sftp
  32. apt-get -y install expect > /dev/null 2>&1
  33. # apparmor rules for bind9
  34. if [ -f "/etc/bind/named.conf" ]; then
  35. file="/etc/apparmor.d/local/usr.sbin.named"
  36. if [ ! -f "$file" ] || [ $( grep -ic "/home/" $file ) -eq 0 ]; then
  37. aa-complain /usr/sbin/named 2>/dev/null
  38. echo "/home/** rwm," >> /etc/apparmor.d/local/usr.sbin.named 2>/dev/null
  39. service apparmor restart >/dev/null 2>&1
  40. fi
  41. fi
  42. # Debian fix for spamassassin when it's not in startup list
  43. if [[ $(systemctl list-unit-files | grep spamassassin) =~ "disabled" ]]; then
  44. systemctl enable spamassassin
  45. fi
  46. # RoundCube tinyMCE fix
  47. if [ "$release" -eq '8' ]; then
  48. tinymceFixArchiveURL=$vestacp/roundcube/roundcube-tinymce.tar.gz
  49. tinymceParentFolder=/usr/share/roundcube/program/js
  50. tinymceFolder=$tinymceParentFolder/tinymce
  51. tinymceBadJS=$tinymceFolder/tiny_mce.js
  52. tinymceFixArchive=$tinymceParentFolder/roundcube-tinymce.tar.gz
  53. if [[ -L "$tinymceFolder" && -d "$tinymceFolder" ]]; then
  54. if [ -f "$tinymceBadJS" ]; then
  55. wget $tinymceFixArchiveURL -O $tinymceFixArchive
  56. if [[ -f "$tinymceFixArchive" && -s "$tinymceFixArchive" ]]; then
  57. rm $tinymceFolder
  58. tar -xzf $tinymceFixArchive -C $tinymceParentFolder
  59. rm $tinymceFixArchive
  60. chown -R root:root $tinymceFolder
  61. else
  62. echo "File roundcube-tinymce.tar.gz is not downloaded, RoundCube tinyMCE fix is not applied"
  63. rm $tinymceFixArchive
  64. fi
  65. fi
  66. fi
  67. fi
  68. # Fixing empty NAT ip
  69. ip=$(ip addr|grep 'inet '|grep global|head -n1|awk '{print $2}'|cut -f1 -d/)
  70. pub_ip=$(curl -s vestacp.com/what-is-my-ip/)
  71. file="$VESTA/data/ips/$ip"
  72. if [ -f "$file" ] && [ $( grep -ic "NAT=''" $file ) -eq 1 ]; then
  73. if [ ! -z "$pub_ip" ] && [ "$pub_ip" != "$ip" ]; then
  74. v-change-sys-ip-nat $ip $pub_ip
  75. fi
  76. fi
  77. # Installing libmail-dkim-perl for better DKIM handling in Spamassassin
  78. file="/etc/exim4/exim4.conf.template"
  79. if [ -f "$file" ]; then
  80. apt-get -y install libmail-dkim-perl > /dev/null 2>&1
  81. fi
  82. # Switching to mod_remoteip
  83. if [ ! -f "/etc/apache2/mods-enabled/remoteip.load" ]; then
  84. $VESTA/upd/switch_rpath.sh
  85. fi
  86. # Removing AllowSupplementaryGroups from clamav.conf
  87. if [ -f "/etc/clamav/clamd.conf" ]; then
  88. file="/etc/clamav/clamd.conf"
  89. if [ $( grep -ic "# AllowSupplementaryGroups" $file ) -eq 0 ]; then
  90. sed -i "s/AllowSupplementaryGroups/# AllowSupplementaryGroups/g" $file
  91. service clamav-daemon restart
  92. fi
  93. fi
  94. # Fixing /var/run/clamav permissions
  95. if [ -f "/lib/systemd/system/clamav-daemon.service" ]; then
  96. file="/lib/systemd/system/clamav-daemon.service"
  97. if [ $( grep -ic "mkdir" $file ) -eq 0 ]; then
  98. sed -i "s/\[Service\]/\[Service\]\nExecStartPre = \/bin\/mkdir -p \/var\/run\/clamav\nExecStartPre = \/bin\/chown -R clamav:clamav \/var\/run\/clamav/g" $file
  99. if [ ! -d "/var/run/clamav" ]; then
  100. mkdir /var/run/clamav
  101. fi
  102. chown -R clamav:clamav /var/run/clamav
  103. service clamav-daemon restart > /dev/null 2>&1
  104. fi
  105. fi