Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2018
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.56 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # OS VERSION: CentOS 6.4+ Minimal
  4. # ARCH: 32bit + 64bit
  5.  
  6. ZPX_VERSION=10.1.1
  7.  
  8. # Official ZPanel Automated Installation Script
  9. # =============================================
  10. #
  11. # This program is free software: you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation, either version 3 of the License, or
  14. # (at your option) any later version.
  15. #
  16. # This program is distributed in the hope that it will be useful,
  17. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. # GNU General Public License for more details.
  20. #
  21. # You should have received a copy of the GNU General Public License
  22. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. #
  24.  
  25. # First we check if the user is 'root' before allowing installation to commence
  26. if [ $UID -ne 0 ]; then
  27. echo "Installed failed! To install you must be logged in as 'root', please try again"
  28. exit 1
  29. fi
  30.  
  31. # Lets check for some common control panels that we know will affect the installation/operating of ZPanel.
  32. if [ -e /usr/local/cpanel ] || [ -e /usr/local/directadmin ] || [ -e /usr/local/solusvm/www ] || [ -e /usr/local/home/admispconfig ] || [ -e /usr/local/lxlabs/kloxo ] ; then
  33. echo "You appear to have a control panel already installed on your server; This installer"
  34. echo "is designed to install and configure ZPanel on a clean OS installation only!"
  35. echo ""
  36. echo "Please re-install your OS before attempting to install using this script."
  37. exit
  38. fi
  39.  
  40. if rpm -q php httpd mysql bind postfix dovecot;
  41. then
  42. echo "You appear to have a server with apache/mysql/bind/postfix already installed; "
  43. echo "This installer is designed to install and configure ZPanel on a clean OS "
  44. echo "installation only!"
  45. echo ""
  46. echo "Please re-install your OS before attempting to install using this script."
  47. exit
  48. exit
  49. fi
  50.  
  51. # Ensure the installer is launched and can only be launched on CentOs 6.4
  52. BITS=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
  53. if [ -f /etc/centos-release ]; then
  54. OS="CentOs"
  55. VER=$(cat /etc/centos-release | sed 's/^.*release //;s/ (Fin.*$//')
  56. else
  57. OS=$(uname -s)
  58. VER=$(uname -r)
  59. fi
  60. echo "Detected : $OS $VER $BITS"
  61. #warning the last version of centos and 6.x
  62. if [ "$OS" = "CentOs" ] && [ "$VER" = "6.0" ] || [ "$VER" = "6.1" ] || [ "$VER" = "6.2" ] || [ "$VER" = "6.3" ] || [ "$VER" = "6.4" ] || [ "$VER" = "6.5" ] ||[ "$VER" = "6.6" ]||[ "$VER" = "6.7" ]||[ "$VER" = "6.8" ]||[ "$VER" = "6.9" ]||[ "$VER" = "6.10" ] ; then
  63. echo "Ok."
  64. else
  65. echo "Sorry, this installer only supports the installation of ZPanel on CentOS 6.x."
  66. exit 1;
  67. fi
  68.  
  69. # Set custom logging methods so we create a log file in the current working directory.
  70. logfile=$$.log
  71. touch $$.log
  72. exec > >(tee $logfile)
  73. exec 2>&1
  74.  
  75. # ***************************************
  76. # * Common installer functions *
  77. # ***************************************
  78.  
  79. # Generates random passwords fro the 'zadmin' account as well as Postfix and MySQL root account.
  80. passwordgen() {
  81. l=$1
  82. [ "$l" == "" ] && l=16
  83. tr -dc A-Za-z0-9 < /dev/urandom | head -c ${l} | xargs
  84. }
  85.  
  86. # Display the 'welcome' splash/user warning info..
  87. echo -e "##############################################################"
  88. echo -e "# Welcome to the Official ZPanelX Installer for CentOS 6.4 #"
  89. echo -e "# #"
  90. echo -e "# Please make sure your VPS provider hasn't pre-installed #"
  91. echo -e "# any packages required by ZPanelX. #"
  92. echo -e "# #"
  93. echo -e "# If you are installing on a physical machine where the OS #"
  94. echo -e "# has been installed by yourself please make sure you only #"
  95. echo -e "# installed CentOS with no extra packages. #"
  96. echo -e "# #"
  97. echo -e "# If you selected additional options during the CentOS #"
  98. echo -e "# install please consider reinstalling without them. #"
  99. echo -e "# #"
  100. echo -e "##############################################################"
  101.  
  102. # Set some installation defaults/auto assignments
  103. fqdn=`/bin/hostname`
  104. publicip=`wget -qO- http://api.zpanelcp.com/ip.txt`
  105.  
  106. # Lets check that the user wants to continue first...
  107. while true; do
  108. read -e -p "Would you like to continue (y/n)? " yn
  109. case $yn in
  110. [Yy]* ) break;;
  111. [Nn]* ) exit;
  112. esac
  113. done
  114.  
  115. #a selection list for the time zone is not better now?
  116. yum -y -q install tzdata &>/dev/null
  117. echo "echo \$TZ > /etc/timezone" >> /usr/bin/tzselect
  118.  
  119. # Installer options
  120. while true; do
  121. echo -e "Find your timezone from : http://php.net/manual/en/timezones.php e.g Europe/London"
  122. tzselect
  123. tz=`cat /etc/timezone`
  124. echo -e "Enter the FQDN you will use to access ZPanel on your server."
  125. echo -e "- It MUST be a sub-domain of you main domain, it MUST NOT be your main domain only. Example: panel.yourdomain.com"
  126. echo -e "- Remember that the sub-domain ('panel' in the example) MUST be setup in your DNS nameserver."
  127. read -e -p "FQDN for zpanel: " -i $fqdn fqdn
  128. read -e -p "Enter the public (external) server IP: " -i $publicip publicip
  129. read -e -p "ZPanel is now ready to install, do you wish to continue (y/n)" yn
  130. case $yn in
  131. [Yy]* ) break;;
  132. [Nn]* ) exit;
  133. esac
  134. done
  135.  
  136. #to remedy some problems of compatibility use of mirror centos.org to all users
  137. #CentOS-Base.repo
  138.  
  139. #released Base
  140. sed -i 's|mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os|#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os|' "/etc/yum.repos.d/CentOS-Base.repo"
  141. sed -i 's|#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/|baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/|' "/etc/yum.repos.d/CentOS-Base.repo"
  142. #released Updates
  143. sed -i 's|mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates|#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates|' "/etc/yum.repos.d/CentOS-Base.repo"
  144. sed -i 's|#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/|baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/|' "/etc/yum.repos.d/CentOS-Base.repo"
  145. #additional packages that may be useful Centos Extra
  146. sed -i 's|mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras|#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras|' "/etc/yum.repos.d/CentOS-Base.repo"
  147. sed -i 's|#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/|baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/|' "/etc/yum.repos.d/CentOS-Base.repo"
  148. #additional packages that extend functionality of existing packages Centos Plus
  149. sed -i 's|mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus|#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus|' "/etc/yum.repos.d/CentOS-Base.repo"
  150. sed -i 's|#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/|baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/|' "/etc/yum.repos.d/CentOS-Base.repo"
  151. #contrib - packages by Centos Users
  152. sed -i 's|mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib|#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib|' "/etc/yum.repos.d/CentOS-Base.repo"
  153. sed -i 's|#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/|baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/|' "/etc/yum.repos.d/CentOS-Base.repo"
  154.  
  155. #check if the machine and on openvz
  156. if [ -f "/etc/yum.repos.d/vz.repo" ]; then
  157. #vz.repo
  158. sed -i 's|mirrorlist=http://vzdownload.swsoft.com/download/mirrors/centos-6|baseurl=http://vzdownload.swsoft.com/ez/packages/centos/6/$basearch/os/|' "/etc/yum.repos.d/vz.repo"
  159. sed -i 's|mirrorlist=http://vzdownload.swsoft.com/download/mirrors/updates-released-ce6|baseurl=http://vzdownload.swsoft.com/ez/packages/centos/6/$basearch/updates/|' "/etc/yum.repos.d/vz.repo"
  160. fi
  161.  
  162. #disable deposits that could result in installation errors
  163. #repo ELRepo
  164. if [ -f "/etc/yum.repos.d/elrepo.repo" ]; then
  165. sed -i 's/enabled=1/enabled=0/g' "/etc/yum.repos.d/elrepo.repo"
  166. fi
  167.  
  168. #repo Epel Testing
  169. if [ -f "/etc/yum.repos.d/epel-testing.repo" ]; then
  170. sed -i 's/enabled=1/enabled=0/g' "/etc/yum.repos.d/epel-testing.repo"
  171. fi
  172.  
  173. #repo Remi
  174. if [ -f "/etc/yum.repos.d/remi.repo" ]; then
  175. sed -i 's/enabled=1/enabled=0/g' "/etc/yum.repos.d/remi.repo"
  176. fi
  177.  
  178. #repo RPMForge
  179. if [ -f "/etc/yum.repos.d/rpmforge.repo" ]; then
  180. sed -i 's/enabled=1/enabled=0/g' "/etc/yum.repos.d/rpmforge.repo"
  181. fi
  182.  
  183. #repo RPMFusion Free Updates
  184. if [ -f "/etc/yum.repos.d/rpmfusion-free-updates.repo" ]; then
  185. sed -i 's/enabled=1/enabled=0/g' "/etc/yum.repos.d/rpmfusion-free-updates.repo"
  186. fi
  187.  
  188. #repo RPMFusion Free Updates Testing
  189. if [ -f "/etc/yum.repos.d/rpmfusion-free-updates-testing.repo" ]; then
  190. sed -i 's/enabled=1/enabled=0/g' "/etc/yum.repos.d/rpmfusion-free-updates-testing.repo"
  191. fi
  192.  
  193. # We need to disable SELinux...
  194. sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
  195. setenforce 0
  196.  
  197. # We now stop IPTables to ensure a fully automated and pain free installation.
  198. service iptables save
  199. service iptables stop
  200. chkconfig sendmail off
  201. chkconfig iptables off
  202.  
  203. # Start log creation.
  204. echo -e ""
  205. echo -e "# Generating installation log and debug info..."
  206. uname -a
  207. echo -e ""
  208. rpm -qa
  209.  
  210. # Removal of conflicting packages and services prior to ZPX installation.
  211. service sendmail stop
  212. yum -y remove bind-chroot
  213.  
  214. # Install some standard utility packages required by the installer and/or ZPX.
  215. yum -y install sudo wget vim make zip unzip git chkconfig
  216.  
  217.  
  218. # We now clone the ZPX software from GitHub
  219. echo "Downloading ZPanel, Please wait, this may take several minutes, the installer will continue after this is complete!"
  220. git clone https://github.com/zpanel/zpanelx.git
  221. cd zpanelx/
  222. git checkout $ZPX_VERSION
  223. mkdir ../zp_install_cache/
  224. git checkout-index -a -f --prefix=../zp_install_cache/
  225. cd ../zp_install_cache/
  226.  
  227. # Lets pull in all the required updates etc.
  228. rpm --import https://fedoraproject.org/static/0608B895.txt
  229. cp etc/build/config_packs/centos_6_3/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo
  230.  
  231. # problem upgrade centos 6.2 with 6.5 pacquet deteted as repo qpid-cpp-client
  232. yum -y remove qpid-cpp-client
  233. # We now update the server software packages.
  234. yum -y update
  235. yum -y upgrade
  236.  
  237. # Install required software and dependencies required by ZPanel.
  238. yum -y install ld-linux.so.2 libbz2.so.1 libdb-4.7.so libgd.so.2 httpd php php-suhosin php-devel php-gd php-mbstring php-mcrypt php-intl php-imap php-mysql php-xml php-xmlrpc curl curl-devel perl-libwww-perl libxml2 libxml2-devel mysql-server zip webalizer gcc gcc-c++ httpd-devel at make mysql-devel bzip2-devel postfix postfix-perl-scripts bash-completion dovecot dovecot-mysql dovecot-pigeonhole mysql-server proftpd proftpd-mysql bind bind-utils bind-libs
  239.  
  240. # Generation of random passwords
  241. password=`passwordgen`;
  242. postfixpassword=`passwordgen`;
  243. zadminNewPass=`passwordgen`;
  244.  
  245. # Set-up ZPanel directories and configure directory permissions as required.
  246. mkdir /etc/zpanel
  247. mkdir /etc/zpanel/configs
  248. mkdir /etc/zpanel/panel
  249. mkdir /etc/zpanel/docs
  250. mkdir /var/zpanel
  251. mkdir /var/zpanel/hostdata
  252. mkdir /var/zpanel/hostdata/zadmin
  253. mkdir /var/zpanel/hostdata/zadmin/public_html
  254. mkdir /var/zpanel/logs
  255. mkdir /var/zpanel/logs/proftpd
  256. mkdir /var/zpanel/backups
  257. mkdir /var/zpanel/temp
  258. cp -R . /etc/zpanel/panel/
  259. chmod -R 777 /etc/zpanel/
  260. chmod -R 777 /var/zpanel/
  261. chmod -R 770 /var/zpanel/hostdata/
  262. chown -R apache:apache /var/zpanel/hostdata/
  263. chmod 644 /etc/zpanel/panel/etc/apps/phpmyadmin/config.inc.php
  264. ln -s /etc/zpanel/panel/bin/zppy /usr/bin/zppy
  265. ln -s /etc/zpanel/panel/bin/setso /usr/bin/setso
  266. ln -s /etc/zpanel/panel/bin/setzadmin /usr/bin/setzadmin
  267. chmod +x /etc/zpanel/panel/bin/zppy
  268. chmod +x /etc/zpanel/panel/bin/setso
  269. cp -R /etc/zpanel/panel/etc/build/config_packs/centos_6_3/. /etc/zpanel/configs/
  270. # set password after test connexion
  271. cc -o /etc/zpanel/panel/bin/zsudo /etc/zpanel/configs/bin/zsudo.c
  272. sudo chown root /etc/zpanel/panel/bin/zsudo
  273. chmod +s /etc/zpanel/panel/bin/zsudo
  274.  
  275. # MySQL specific installation tasks...
  276. service mysqld start
  277. mysqladmin -u root password "$password"
  278. until mysql -u root -p$password -e ";" > /dev/null 2>&1 ; do
  279. read -s -p "enter your root mysql password : " password
  280. done
  281. sed -i "s|YOUR_ROOT_MYSQL_PASSWORD|$password|" /etc/zpanel/panel/cnf/db.php
  282. mysql -u root -p$password -e "DELETE FROM mysql.user WHERE User='root' AND Host != 'localhost'";
  283. mysql -u root -p$password -e "DELETE FROM mysql.user WHERE User=''";
  284. mysql -u root -p$password -e "DROP DATABASE test";
  285. mysql -u root -p$password -e "CREATE SCHEMA zpanel_roundcube";
  286. cat /etc/zpanel/configs/zpanelx-install/sql/*.sql | mysql -u root -p$password
  287. mysql -u root -p$password -e "UPDATE mysql.user SET Password=PASSWORD('$postfixpassword') WHERE User='postfix' AND Host='localhost';";
  288. mysql -u root -p$password -e "FLUSH PRIVILEGES";
  289. sed -i "/symbolic-links=/a \secure-file-priv=/var/tmp" /etc/my.cnf
  290.  
  291. # Set some ZPanel custom configuration settings (using. setso and setzadmin)
  292. /etc/zpanel/panel/bin/setzadmin --set "$zadminNewPass";
  293. /etc/zpanel/panel/bin/setso --set zpanel_domain $fqdn
  294. /etc/zpanel/panel/bin/setso --set server_ip $publicip
  295. /etc/zpanel/panel/bin/setso --set apache_changed "true"
  296.  
  297. # We'll store the passwords so that users can review them later if required.
  298. touch /root/passwords.txt;
  299. echo "zadmin Password: $zadminNewPass" >> /root/passwords.txt;
  300. echo "MySQL Root Password: $password" >> /root/passwords.txt
  301. echo "MySQL Postfix Password: $postfixpassword" >> /root/passwords.txt
  302. echo "IP Address: $publicip" >> /root/passwords.txt
  303. echo "Panel Domain: $fqdn" >> /root/passwords.txt
  304.  
  305. # Postfix specific installation tasks...
  306. sed -i "s|;date.timezone =|date.timezone = $tz|" /etc/php.ini
  307. sed -i "s|;upload_tmp_dir =|upload_tmp_dir = /var/zpanel/temp/|" /etc/php.ini
  308. mkdir /var/zpanel/vmail
  309. chmod -R 770 /var/zpanel/vmail
  310. useradd -r -u 101 -g mail -d /var/zpanel/vmail -s /sbin/nologin -c "Virtual mailbox" vmail
  311. chown -R vmail:mail /var/zpanel/vmail
  312. mkdir -p /var/spool/vacation
  313. useradd -r -d /var/spool/vacation -s /sbin/nologin -c "Virtual vacation" vacation
  314. chmod -R 770 /var/spool/vacation
  315. ln -s /etc/zpanel/configs/postfix/vacation.pl /var/spool/vacation/vacation.pl
  316. postmap /etc/postfix/transport
  317. chown -R vacation:vacation /var/spool/vacation
  318. if ! grep -q "127.0.0.1 autoreply.$fqdn" /etc/hosts; then echo "127.0.0.1 autoreply.$fqdn" >> /etc/hosts; fi
  319. sed -i "s|myhostname = control.yourdomain.com|myhostname = $fqdn|" /etc/zpanel/configs/postfix/main.cf
  320. sed -i "s|mydomain = control.yourdomain.com|mydomain = $fqdn|" /etc/zpanel/configs/postfix/main.cf
  321. rm -rf /etc/postfix/main.cf /etc/postfix/master.cf
  322. ln -s /etc/zpanel/configs/postfix/master.cf /etc/postfix/master.cf
  323. ln -s /etc/zpanel/configs/postfix/main.cf /etc/postfix/main.cf
  324. sed -i "s|password \= postfix|password \= $postfixpassword|" /etc/zpanel/configs/postfix/mysql-relay_domains_maps.cf
  325. sed -i "s|password \= postfix|password \= $postfixpassword|" /etc/zpanel/configs/postfix/mysql-virtual_alias_maps.cf
  326. sed -i "s|password \= postfix|password \= $postfixpassword|" /etc/zpanel/configs/postfix/mysql-virtual_domains_maps.cf
  327. sed -i "s|password \= postfix|password \= $postfixpassword|" /etc/zpanel/configs/postfix/mysql-virtual_mailbox_limit_maps.cf
  328. sed -i "s|password \= postfix|password \= $postfixpassword|" /etc/zpanel/configs/postfix/mysql-virtual_mailbox_maps.cf
  329. sed -i "s|\$db_password \= 'postfix';|\$db_password \= '$postfixpassword';|" /etc/zpanel/configs/postfix/vacation.conf
  330.  
  331. # Dovecot specific installation tasks (includes Sieve)
  332. mkdir /var/zpanel/sieve
  333. chown -R vmail:mail /var/zpanel/sieve
  334. mkdir /var/lib/dovecot/sieve/
  335. touch /var/lib/dovecot/sieve/default.sieve
  336. ln -s /etc/zpanel/configs/dovecot2/globalfilter.sieve /var/zpanel/sieve/globalfilter.sieve
  337. rm -rf /etc/dovecot/dovecot.conf
  338. ln -s /etc/zpanel/configs/dovecot2/dovecot.conf /etc/dovecot/dovecot.conf
  339. sed -i "s|postmaster_address = postmaster@your-domain.tld|postmaster_address = postmaster@$fqdn|" /etc/dovecot/dovecot.conf
  340. sed -i "s|password=postfix|password=$postfixpassword|" /etc/zpanel/configs/dovecot2/dovecot-dict-quota.conf
  341. sed -i "s|password=postfix|password=$postfixpassword|" /etc/zpanel/configs/dovecot2/dovecot-mysql.conf
  342. touch /var/log/dovecot.log
  343. touch /var/log/dovecot-info.log
  344. touch /var/log/dovecot-debug.log
  345. chown vmail:mail /var/log/dovecot*
  346. chmod 660 /var/log/dovecot*
  347.  
  348. # ProFTPD specific installation tasks
  349. groupadd -g 2001 ftpgroup
  350. useradd -u 2001 -s /bin/false -d /bin/null -c "proftpd user" -g ftpgroup ftpuser
  351. sed -i "s|zpanel_proftpd@localhost root z|zpanel_proftpd@localhost root $password|" /etc/zpanel/configs/proftpd/proftpd-mysql.conf
  352. rm -rf /etc/proftpd.conf
  353. touch /etc/proftpd.conf
  354. if ! grep -q "include /etc/zpanel/configs/proftpd/proftpd-mysql.conf" /etc/proftpd.conf; then echo "include /etc/zpanel/configs/proftpd/proftpd-mysql.conf" >> /etc/proftpd.conf; fi
  355. chmod -R 644 /var/zpanel/logs/proftpd
  356. serverhost=`hostname`
  357.  
  358. # Apache HTTPD specific installation tasks...
  359. if ! grep -q "Include /etc/zpanel/configs/apache/httpd.conf" /etc/httpd/conf/httpd.conf; then echo "Include /etc/zpanel/configs/apache/httpd.conf" >> /etc/httpd/conf/httpd.conf; fi
  360. if ! grep -q "127.0.0.1 "$fqdn /etc/hosts; then echo "127.0.0.1 "$fqdn >> /etc/hosts; fi
  361. if ! grep -q "apache ALL=NOPASSWD: /etc/zpanel/panel/bin/zsudo" /etc/sudoers; then echo "apache ALL=NOPASSWD: /etc/zpanel/panel/bin/zsudo" >> /etc/sudoers; fi
  362. sed -i 's|DocumentRoot "/var/www/html"|DocumentRoot "/etc/zpanel/panel"|' /etc/httpd/conf/httpd.conf
  363. chown -R apache:apache /var/zpanel/temp/
  364. #Set keepalive on (default is off)
  365. sed -i "s|KeepAlive Off|KeepAlive On|" /etc/httpd/conf/httpd.conf
  366.  
  367. # PHP specific installation tasks...
  368. sed -i "s|;date.timezone =|date.timezone = $tz|" /etc/php.ini
  369. sed -i "s|;upload_tmp_dir =|upload_tmp_dir = /var/zpanel/temp/|" /etc/php.ini
  370. #Disable php signature in headers to hide it from hackers
  371. sed -i "s|expose_php = On|expose_php = Off|" /etc/php.ini
  372.  
  373. # Permissions fix for Apache and ProFTPD (to enable them to play nicely together!)
  374. if ! grep -q "umask 002" /etc/sysconfig/httpd; then echo "umask 002" >> /etc/sysconfig/httpd; fi
  375. if ! grep -q "127.0.0.1 $serverhost" /etc/hosts; then echo "127.0.0.1 $serverhost" >> /etc/hosts; fi
  376. usermod -a -G apache ftpuser
  377. usermod -a -G ftpgroup apache
  378.  
  379. # BIND specific installation tasks...
  380. chmod -R 777 /etc/zpanel/configs/bind/zones/
  381. chmod 751 /var/named
  382. chmod 771 /var/named/data
  383. rm -rf /etc/named.conf /etc/rndc.conf /etc/rndc.key
  384. rndc-confgen -a
  385. ln -s /etc/zpanel/configs/bind/named.conf /etc/named.conf
  386. ln -s /etc/zpanel/configs/bind/rndc.conf /etc/rndc.conf
  387. cat /etc/rndc.key /etc/named.conf | tee named.conf > /dev/null
  388. cat /etc/rndc.key /etc/rndc.conf | tee named.conf > /dev/null
  389.  
  390. # CRON specific installation tasks...
  391. mkdir -p /var/spool/cron/
  392. mkdir -p /etc/cron.d/
  393. touch /var/spool/cron/apache
  394. touch /etc/cron.d/apache
  395. crontab -u apache /var/spool/cron/apache
  396. cp /etc/zpanel/configs/cron/zdaemon /etc/cron.d/zdaemon
  397. chmod 744 /var/spool/cron
  398. chmod 644 /var/spool/cron/apache
  399. chmod -R 644 /etc/cron.d/
  400. chown -R apache:apache /var/spool/cron/
  401.  
  402. # Webalizer specific installation tasks...
  403. rm -rf /etc/webalizer.conf
  404.  
  405. # Roundcube specific installation tasks...
  406. sed -i "s|YOUR_MYSQL_ROOT_PASSWORD|$password|" /etc/zpanel/configs/roundcube/db.inc.php
  407. sed -i "s|#||" /etc/zpanel/configs/roundcube/db.inc.php
  408. rm -rf /etc/zpanel/panel/etc/apps/webmail/config/main.inc.php
  409. ln -s /etc/zpanel/configs/roundcube/main.inc.php /etc/zpanel/panel/etc/apps/webmail/config/main.inc.php
  410. ln -s /etc/zpanel/configs/roundcube/config.inc.php /etc/zpanel/panel/etc/apps/webmail/plugins/managesieve/config.inc.php
  411. ln -s /etc/zpanel/configs/roundcube/db.inc.php /etc/zpanel/panel/etc/apps/webmail/config/db.inc.php
  412.  
  413. # Enable system services and start/restart them as required.
  414. chkconfig httpd on
  415. chkconfig postfix on
  416. chkconfig dovecot on
  417. chkconfig crond on
  418. chkconfig mysqld on
  419. chkconfig named on
  420. chkconfig proftpd on
  421. service httpd start
  422. service postfix restart
  423. service dovecot start
  424. service crond start
  425. service mysqld restart
  426. service named start
  427. service proftpd start
  428. service atd start
  429. php /etc/zpanel/panel/bin/daemon.php
  430. # restart all service
  431. service httpd restart
  432. service postfix restart
  433. service dovecot restart
  434. service crond restart
  435. service mysqld restart
  436. service named restart
  437. service proftpd restart
  438. service atd restart
  439.  
  440. # We'll now remove the temporary install cache.
  441. cd ../
  442. rm -rf zp_install_cache/ zpanelx/
  443.  
  444. # Advise the user that ZPanel is now installed and accessible.
  445. echo -e "##############################################################" &>/dev/tty
  446. echo -e "# Congratulations ZpanelX has now been installed on your #" &>/dev/tty
  447. echo -e "# server. Please review the log file left in /root/ for #" &>/dev/tty
  448. echo -e "# any errors encountered during installation. #" &>/dev/tty
  449. echo -e "# #" &>/dev/tty
  450. echo -e "# Save the following information somewhere safe: #" &>/dev/tty
  451. echo -e "# MySQL Root Password : $password" &>/dev/tty
  452. echo -e "# MySQL Postfix Password : $postfixpassword" &>/dev/tty
  453. echo -e "# ZPanelX Username : zadmin #" &>/dev/tty
  454. echo -e "# ZPanelX Password : $zadminNewPass" &>/dev/tty
  455. echo -e "# #" &>/dev/tty
  456. echo -e "# ZPanelX Web login can be accessed using your server IP #" &>/dev/tty
  457. echo -e "# inside your web browser. #" &>/dev/tty
  458. echo -e "# #" &>/dev/tty
  459. echo -e "##############################################################" &>/dev/tty
  460. echo -e "" &>/dev/tty
  461.  
  462. # We now request that the user restarts their server...
  463. while true; do
  464. read -e -p "Restart your server now to complete the install (y/n)? " rsn
  465. case $rsn in
  466. [Yy]* ) break;;
  467. [Nn]* ) exit;
  468. esac
  469. done
  470. shutdown -r now
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement