SHARE
TWEET

ZPanel Debian Install Script

a guest Oct 19th, 2011 1,043 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. #
  3. # Ubuntu Linux Installation Script for Zpanel 6.1.0 (Development Enviroment)
  4. # Script written by Bobby Allen (ballen@zpanel.co.uk) 14/05/2011
  5. #
  6. #
  7.  
  8. # Apache HTTPD configuration file path
  9. apache_config=/etc/apache2/apache2.conf
  10.  
  11. # ProFTPd configuration file path
  12. proftpd_config=/etc/proftpd/proftpd.conf
  13.  
  14. # PostFix configuration files
  15. postfix_main_config=/etc/postfix/main.cf
  16. postfix_master_config=/etc/postfix/master.cf
  17. mysql_relay_domains_maps=/etc/postfix/mysql_relay_domains_maps.cf
  18. mysql_virtual_alias_maps=/etc/postfix/mysql_virtual_alias_maps.cf
  19. mysql_virtual_domains_maps=/etc/postfix/mysql_virtual_domains_maps.cf
  20. mysql_virtual_mailbox_limit_maps=/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
  21. mysql_virtual_mailbox_maps=/etc/postfix/mysql_virtual_mailbox_maps.cf
  22. mysql_virtual_transport=/etc/postfix/mysql_virtual_transport.cf
  23.  
  24. # Dovecot configuration files
  25. dovecot_config=/etc/dovecot/dovecot.conf
  26. dovecot_sql_config=/etc/postfix/dovecot-sql.conf
  27. dovecot_trash_config=/etc/postfix/dovecot-trash.conf
  28.  
  29. # Make sure we are root
  30. [ $(whoami) == "root" ] && echo "You are root" || echo "You must be root" && exit
  31.  
  32. clear
  33. echo "#########################################################"
  34. echo "# ZPanel Installation Package for Ubuntu Linux          #"
  35. echo "# --------------------------------------------          #"
  36. echo "# Package maintainer: Bobby Allen (ballen@zpanelcp.com) #"
  37. echo "# Last updated:       04/06/2011                        #"
  38. echo "# Website:            http://www.zpanelcp.com           #"
  39. echo "########################################################"
  40. echo ""
  41. echo "Welcome to the online installer for ZPanel, this will download the required software and install ZPanel."
  42. echo ""
  43. echo "This install script is designed to be used on freshly installed servers or workstations"
  44. echo "due to the nature of the software and amount of system changes it makes we recommend that"
  45. echo "if you want to uninstall ZPanel that you re-install your OS."
  46. echo ""
  47. echo "We also recommend that ZPanel is installed on a dedicated server for security reasons!"
  48. echo ""
  49. echo "Are you sure you want to continue? Press ENTER to continue or CTRL+C to quit!"
  50. read continue
  51.  
  52.  
  53. # Install the required development enviroment packages...
  54. echo "#########################################################"
  55. echo "# Updating package repository cache.                    #"
  56. echo "# --------------------------------------------          #"
  57. echo "########################################################"
  58. apt-get update
  59. echo "#########################################################"
  60. echo "# Installing Apache, PHP, MySQL etc.                    #"
  61. echo "# --------------------------------------------          #"
  62. echo "########################################################"
  63. apt-get install apache2 libapache2-mod-php5 libapache2-mod-bw php5 php5-cli php5-common php5-mysql php5-curl php5-gd php-pear php5-imagick php5-imap php5-mcrypt php5-xmlrpc php5-xsl php5-suhosin mysql-server mysql-client zip proftpd webalizer
  64. echo "#########################################################"
  65. echo "# Installing Postfix and Dovecot                        #"
  66. echo "# --------------------------------------------          #"
  67. echo "# When asked please select 'INTERNET SITE'              #"
  68. echo "########################################################"
  69. echo "Press ENTER to continue with the installation..."
  70. read continue
  71. apt-get install postfix postfix-mysql dovecot-imapd dovecot-pop3d dovecot-common libsasl2-modules-sql libsasl2-modules
  72.  
  73. # configure Suhosin
  74. echo "suhosin.session.encrypt = Off" >> /etc/php5/conf.d/suhosin.ini
  75. echo "suhosin.cookie.encrypt = Off" >> /etc/php5/conf.d/suhosin.ini
  76. echo "suhosin.memory.limit = 512M" >> /etc/php5/conf.d/suhosin.ini
  77.  
  78. # Add 'include' to the Apache configuration file..
  79. echo "# Include the ZPanel HTTPD managed configuration file." >> ${apache_config}
  80. echo "Include /etc/zpanel/conf/httpd.conf" >> ${apache_config}
  81.  
  82. # Add 'include' to the ProFTPd configuration file..
  83. echo "# Include the ZPanel ProFTPd managed configuration file." > ${proftpd_config}
  84. echo "Include /etc/zpanel/conf/proftpd.conf" >> ${proftpd_config}
  85.  
  86. # Add exception to Sudoers file to enable zsudo execution for restarting Apache etc.
  87. echo "# ZPanel modification to enable automated Apache restarts." >> /etc/sudoers
  88. echo "www-data ALL=NOPASSWD: /etc/zpanel/bin/zsudo" >> /etc/sudoers
  89.  
  90. # Make the default directories
  91. mkdir /var/zpanel/
  92. mkdir /var/zpanel/logs/
  93. mkdir /var/zpanel/backups/
  94. mkdir /var/zpanel/updates/
  95. mkdir /var/zpanel/hostdata/
  96. mkdir /var/zpanel/temp/
  97. mkdir /var/zpanel/hostdata/zadmin/
  98. mkdir /var/zpanel/logs/domains/
  99. mkdir /var/zpanel/logs/domains/zadmin/
  100. mkdir /var/zpanel/logs/proftpd/
  101.  
  102. # Set the security on these directories
  103. chown -R www-data /etc/zpanel
  104. chmod -R g+s /etc/zpanel
  105. chown -R www-data /var/zpanel
  106. chmod -R g+s /var/zpanel
  107. chmod -R 777 /etc/zpanel/
  108. chmod -R 777 /var/zpanel/
  109. chown root /etc/zpanel/bin/zsudo
  110. chmod 4777 /etc/zpanel/bin/zsudo
  111.  
  112. # Restart ProFTPd and Apache...
  113. /etc/init.d/proftpd restart
  114. /etc/init.d/apache2 restart
  115.  
  116. echo "###############################################################"
  117. echo "# Import ZPanel SQL Databases                                 #"
  118. echo "# -------------------------------------------------           #"
  119. echo "# Please now enter the root MySQL password so I can           #"
  120. echo "# import the databases and create the ZPanel DB config file.. #"
  121. echo "##############################################################"
  122. read defaultpassword
  123. echo "> Importing zpanel_core database.."
  124. mysql -uroot -p${defaultpassword} < /etc/zpanel/lib/dev/zpanel_core.sql
  125. echo "  ^ Done"
  126. echo "> Importing zpanel_postfix database.."
  127. mysql -uroot -p${defaultpassword} < /etc/zpanel/lib/dev/zpanel_postfix.sql
  128. echo "  ^ Done!"
  129. echo "> Importing the zpanel_roundcube database"
  130. mysql -uroot -p${defaultpassword} < /etc/zpanel/lib/dev/zpanel_roundcube.sql
  131. echo "  ^ Done!"
  132. echo "> Writing the zpanel database configuration file.."
  133.  
  134. # Setup the default virtual host for the control panel and get ZPanel Setup Information
  135. clear
  136. echo "#########################################################"
  137. echo "# ZPanel Configuration Details                          #"
  138. echo "# --------------------------------------------          #"
  139. echo "########################################################"
  140. echo "ADMIN ACCOUNT DETAILS:"
  141. echo "Your first name:"
  142. read firstname
  143. echo "Your last name:"
  144. read lastname
  145. echo "Your email address:"
  146. read email
  147. echo ""
  148. echo "ENTER THE SUBDOMAIN THAT WILL HOST ZPANEL EG. 'CONTROL.YOURDOMAIN.COM'"
  149. read domain
  150.  
  151. # Update the zpanel_core database with gathered information
  152. zpassword=$(</dev/urandom tr -dc A-Za-z0-9 | head -c6)
  153. password=$(</dev/urandom tr -dc A-Za-z0-9 | head -c8)
  154. echo "SET PASSWORD FOR root@localhost=PASSWORD('${password}');" |mysql -uroot -p${defaultpassword} -hlocalhost
  155. echo "update z_accounts set ac_pass_vc=MD5('${zpassword}') where ac_user_vc='zadmin';" |mysql -uroot -p${password} -hlocalhost zpanel_core
  156. echo "update z_personal set ap_fullname_vc='${firstname} ${lastname}' where ap_id_pk='2';" |mysql -uroot -p${password} -hlocalhost zpanel_core
  157. echo "update z_personal set ap_email_vc='${email}' where ap_id_pk='2';" |mysql -uroot -p${password} -hlocalhost zpanel_core
  158.  
  159. # Add a cron task to run deamon every 60 mins...
  160. touch /etc/cron.d/zdaemon
  161. echo "0 * * * * root /usr/bin/php -q /etc/zpanel/daemon.php >> /dev/null 2>&1" >> /etc/cron.d/zdaemon
  162. # Permissions must be 644 or cron will not run!
  163. chmod 644 /etc/cron.d/zdaemon
  164. /etc/init.d/cron restart
  165.  
  166. # Create ZPanel Cron file and set permissions
  167. touch /var/spool/cron/crontabs/www-data
  168. chmod 777 /var/spool/cron/crontabs
  169. chown www-data /var/spool/cron/crontabs/www-data
  170. chmod 644 /var/spool/cron/crontabs/www-data
  171.  
  172. echo "#################################################################################" > /var/spool/cron/crontabs/www-data
  173. echo "# CRONTAB FOR ZPANEL CRON MANAGER MODULE                                        #" >> /var/spool/cron/crontabs/www-data
  174. echo "# Module Developed by Bobby Allen, 17/12/2009                                   #" >> /var/spool/cron/crontabs/www-data
  175. echo "#                                                                               #" >> /var/spool/cron/crontabs/www-data
  176. echo "#################################################################################" >> /var/spool/cron/crontabs/www-data
  177. echo "# WE DO NOT RECOMMEND YOU MODIFY THIS FILE DIRECTLY, PLEASE USE ZPANEL INSTEAD! #" >> /var/spool/cron/crontabs/www-data
  178. echo "#################################################################################" >> /var/spool/cron/crontabs/www-data
  179. echo "# DO NOT MANUALLY REMOVE ANY OF THE CRON ENTRIES FROM THIS FILE, USE ZPANEL     #" >> /var/spool/cron/crontabs/www-data
  180. echo "# INSTEAD! THE ABOVE ENTRIES ARE USED FOR ZPANEL TASKS, DO NOT REMOVE THEM!     #" >> /var/spool/cron/crontabs/www-data
  181. echo "#################################################################################" >> /var/spool/cron/crontabs/www-data
  182.  
  183.  
  184. echo "<?php" >> /etc/zpanel/conf/zcnf.php
  185. echo "" >> /etc/zpanel/conf/zcnf.php
  186. echo "/**" >> /etc/zpanel/conf/zcnf.php
  187. echo " *" >> /etc/zpanel/conf/zcnf.php
  188. echo " * ZPanel - A Cross-Platform Open-Source Web Hosting Control panel." >> /etc/zpanel/conf/zcnf.php
  189. echo " * " >> /etc/zpanel/conf/zcnf.php
  190. echo " * @package ZPanel" >> /etc/zpanel/conf/zcnf.php
  191. echo " * @version $Id$" >> /etc/zpanel/conf/zcnf.php
  192. echo " * @author Bobby Allen - ballen@zpanelcp.com" >> /etc/zpanel/conf/zcnf.php
  193. echo " * @copyright (c) 2008-2011 ZPanel Group - http://www.zpanelcp.com/" >> /etc/zpanel/conf/zcnf.php
  194. echo " * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License v3" >> /etc/zpanel/conf/zcnf.php
  195. echo " *" >> /etc/zpanel/conf/zcnf.php
  196. echo " * This program (ZPanel) is free software: you can redistribute it and/or modify" >> /etc/zpanel/conf/zcnf.php
  197. echo " * it under the terms of the GNU General Public License as published by" >> /etc/zpanel/conf/zcnf.php
  198. echo " * the Free Software Foundation, either version 3 of the License, or" >> /etc/zpanel/conf/zcnf.php
  199. echo " * (at your option) any later version." >> /etc/zpanel/conf/zcnf.php
  200. echo " *" >> /etc/zpanel/conf/zcnf.php
  201. echo " * This program is distributed in the hope that it will be useful," >> /etc/zpanel/conf/zcnf.php
  202. echo " * but WITHOUT ANY WARRANTY; without even the implied warranty of" >> /etc/zpanel/conf/zcnf.php
  203. echo " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the" >> /etc/zpanel/conf/zcnf.php
  204. echo " * GNU General Public License for more details." >> /etc/zpanel/conf/zcnf.php
  205. echo " *" >> /etc/zpanel/conf/zcnf.php
  206. echo " * You should have received a copy of the GNU General Public License" >> /etc/zpanel/conf/zcnf.php
  207. echo " * along with this program.  If not, see <http://www.gnu.org/licenses/>." >> /etc/zpanel/conf/zcnf.php
  208. echo " *" >> /etc/zpanel/conf/zcnf.php
  209. echo " */" >> /etc/zpanel/conf/zcnf.php
  210. echo "\$z_db_host = \"localhost\";" >> /etc/zpanel/conf/zcnf.php
  211. echo "\$z_db_name = \"zpanel_core\";" >> /etc/zpanel/conf/zcnf.php
  212. echo "\$z_db_user = \"root\";" >> /etc/zpanel/conf/zcnf.php
  213. echo "\$z_db_pass = \"${password}\";" >> /etc/zpanel/conf/zcnf.php
  214. echo "\$zdb = @mysql_pconnect(\$z_db_host, \$z_db_user, \$z_db_pass) or trigger_error('ZPanel Stack Error :: Unable to connect to ZPanel Database Server (' . \$z_db_host . ').');" >> /etc/zpanel/conf/zcnf.php
  215. echo "?>" >> /etc/zpanel/conf/zcnf.php
  216. echo "  ^ Done"
  217.  
  218. # Set phpmyadmin freindly permissions on the config.inc.php (so phpMyAdmin doesn't complain)
  219. chmod 644 /etc/zpanel/apps/phpmyadmin/config.inc.php
  220.  
  221. echo "# ZPanel Apache Master VHOST file." > /etc/zpanel/conf/httpd-vhosts.conf
  222. echo "# Written by Bobby Allen, 15/05/2011" >> /etc/zpanel/conf/httpd-vhosts.conf
  223. echo "#" >> /etc/zpanel/conf/httpd-vhosts.conf
  224. echo "# DO NOT EDIT THIS FILE MANUALLY - USE ZPANEL TO ADD AND REMOVE VHOSTS!" >> /etc/zpanel/conf/httpd-vhosts.conf
  225. echo " " >> /etc/zpanel/conf/httpd-vhosts.conf
  226. echo "NameVirtualHost *:80" >> /etc/zpanel/conf/httpd-vhosts.conf
  227. echo " " >> /etc/zpanel/conf/httpd-vhosts.conf
  228. echo "  # Configuration for ZPanel control panel." >> /etc/zpanel/conf/httpd-vhosts.conf
  229. echo "  <VirtualHost *:80>" >> /etc/zpanel/conf/httpd-vhosts.conf
  230. echo "  ServerAdmin zadmin@${domain}" >> /etc/zpanel/conf/httpd-vhosts.conf
  231. echo "          DocumentRoot \"/etc/zpanel\"" >> /etc/zpanel/conf/httpd-vhosts.conf
  232. echo "          ServerName ${domain}" >> /etc/zpanel/conf/httpd-vhosts.conf
  233. echo "          ServerAlias *.${domain}" >> /etc/zpanel/conf/httpd-vhosts.conf
  234. echo "  AddType application/x-httpd-php .php" >> /etc/zpanel/conf/httpd-vhosts.conf
  235. echo "  <Directory \"/etc/zpanel\">" >> /etc/zpanel/conf/httpd-vhosts.conf
  236. echo "  Options FollowSymLinks" >> /etc/zpanel/conf/httpd-vhosts.conf
  237. echo "          AllowOverride None" >> /etc/zpanel/conf/httpd-vhosts.conf
  238. echo "          Order allow,deny" >> /etc/zpanel/conf/httpd-vhosts.conf
  239. echo "          Allow from all" >> /etc/zpanel/conf/httpd-vhosts.conf
  240. echo "  </Directory>" >> /etc/zpanel/conf/httpd-vhosts.conf
  241. echo " " >> /etc/zpanel/conf/httpd-vhosts.conf
  242. echo " " >> /etc/zpanel/conf/httpd-vhosts.conf
  243. echo "  </VirtualHost>" >> /etc/zpanel/conf/httpd-vhosts.conf
  244. echo " " >> /etc/zpanel/conf/httpd-vhosts.conf
  245. echo "  ########################################################" >> /etc/zpanel/conf/httpd-vhosts.conf
  246. echo "  # ZPanel generated VHOST configurations below.....     #" >> /etc/zpanel/conf/httpd-vhosts.conf
  247. echo "  ########################################################" >> /etc/zpanel/conf/httpd-vhosts.conf
  248.  
  249. # Add ZPanel CP to hosts file
  250. echo "127.0.0.1                 ${domain}">> /etc/hosts
  251.  
  252. ################################################################################################
  253. # BEGIN Configure Postfix Mail Server ##########################################################
  254. ################################################################################################
  255. # Create a vmail user to store email files
  256. mkdir -p /var/zpanel/vmail
  257. chmod -R 777 /var/zpanel/vmail
  258. chmod -R g+s /var/zpanel/vmail
  259. groupadd -g 5000 vmail
  260. useradd -m -g vmail -u 5000 -d /var/zpanel/vmail -s /bin/bash vmail
  261. chown -R vmail:vmail /var/zpanel/vmail
  262.  
  263. # Postfix Master.cf
  264. echo "# Dovecot LDA" >> ${postfix_master_config}
  265. echo "dovecot   unix  -       n       n       -       -       pipe" >> ${postfix_master_config}
  266. echo "  flags=DRhu user=vmail:mail argv=/usr/lib/dovecot/deliver -d ${recipient}" >> ${postfix_master_config}
  267.  
  268. #BACKUP OLD MAIN CONFIG FOR TESTING
  269. cp ${postfix_main_config} ${postfix_main_config}.old
  270. # Postfix Main.cf
  271. echo "#########################################################################" > ${postfix_main_config}
  272. echo "# HOST CONFIGURATION" >> ${postfix_main_config}
  273. echo "#########################################################################" >> ${postfix_main_config}
  274. echo "myhostname = ${domain}" >> ${postfix_main_config}
  275. echo "mydomain   = ${domain}" >> ${postfix_main_config}
  276. echo "myorigin   = \$myhostname" >> ${postfix_main_config}
  277. echo "#########################################################################" >> ${postfix_main_config}
  278. echo "# MAIN CONFIGURATION" >> ${postfix_main_config}
  279. echo "#########################################################################" >> ${postfix_main_config}
  280. echo "mynetworks          = all" >> ${postfix_main_config}
  281. echo "inet_interfaces     = all" >> ${postfix_main_config}
  282. echo "mydestination       = \$myhostname, localhost.\$mydomain, localhost, \$mydomain" >> ${postfix_main_config}
  283. echo "queue_directory     = /var/spool/postfix" >> ${postfix_main_config}
  284. echo "command_directory   = /usr/sbin" >> ${postfix_main_config}
  285. echo "daemon_directory    = /usr/lib/postfix" >> ${postfix_main_config}
  286. echo "mail_owner          = postfix" >> ${postfix_main_config}
  287. echo "alias_maps          = hash:/etc/aliases" >> ${postfix_main_config}
  288. echo "alias_database      = hash:/etc/aliases" >> ${postfix_main_config}
  289. echo "sendmail_path       = /usr/sbin/sendmail.postfix" >> ${postfix_main_config}
  290. echo "newaliases_path     = /usr/bin/newaliases.postfix" >> ${postfix_main_config}
  291. echo "mailq_path          = /usr/bin/mailq.postfix" >> ${postfix_main_config}
  292. echo "setgid_group        = postdrop" >> ${postfix_main_config}
  293. echo "html_directory      = no" >> ${postfix_main_config}
  294. echo "manpage_directory   = /usr/share/man" >> ${postfix_main_config}
  295. echo "sample_directory    = /usr/share/doc/postfix-2.3.3/samples" >> ${postfix_main_config}
  296. echo "readme_directory    = /usr/share/doc/postfix-2.3.3/README_FILES" >> ${postfix_main_config}
  297. echo "mailbox_size_limit  = 0" >> ${postfix_main_config}
  298. echo "recipient_delimiter = +" >> ${postfix_main_config}
  299. echo "smtpd_helo_required             = yes" >> ${postfix_main_config}
  300. echo "disable_vrfy_command            = yes" >> ${postfix_main_config}
  301. echo "non_fqdn_reject_code            = 450" >> ${postfix_main_config}
  302. echo "invalid_hostname_reject_code    = 450" >> ${postfix_main_config}
  303. echo "maps_rbl_reject_code            = 450" >> ${postfix_main_config}
  304. echo "#unverified_sender_reject_code  = 550" >> ${postfix_main_config}
  305. echo "unknown_local_recipient_reject_code = 550" >> ${postfix_main_config}
  306. echo "#########################################################################" >> ${postfix_main_config}
  307. echo "# SASL CONFIGURATION" >> ${postfix_main_config}
  308. echo "#########################################################################" >> ${postfix_main_config}
  309. echo "smtpd_sasl_auth_enable         = yes" >> ${postfix_main_config}
  310. echo "broken_sasl_auth_clients       = yes" >> ${postfix_main_config}
  311. echo "smtpd_sasl_exceptions_networks = \$mynetworks" >> ${postfix_main_config}
  312. echo "smtpd_sasl_type                = dovecot" >> ${postfix_main_config}
  313. echo "smtpd_sasl_path                = private/auth" >> ${postfix_main_config}
  314. echo "smtpd_sasl_security_options    = noanonymous" >> ${postfix_main_config}
  315. echo "smtpd_recipient_restrictions   = permit_mynetworks," >> ${postfix_main_config}
  316. echo "                   permit_sasl_authenticated," >> ${postfix_main_config}
  317. echo "                           reject_unauth_destination," >> ${postfix_main_config}
  318. echo "                           reject_unauth_pipelining," >> ${postfix_main_config}
  319. echo "                           reject_non_fqdn_sender," >> ${postfix_main_config}
  320. echo "                           reject_non_fqdn_recipient," >> ${postfix_main_config}
  321. echo "                           reject_unknown_sender_domain," >> ${postfix_main_config}
  322. echo "                           reject_unknown_recipient_domain," >> ${postfix_main_config}
  323. echo "                           reject_invalid_helo_hostname," >> ${postfix_main_config}
  324. echo "                   warn_if_reject reject_non_fqdn_helo_hostname," >> ${postfix_main_config}
  325. echo "                   warn_if_reject reject_unknown_helo_hostname," >> ${postfix_main_config}
  326. echo "                   warn_if_reject reject_unknown_client," >> ${postfix_main_config}
  327. echo "                   reject_rbl_client zen.spamhaus.org," >> ${postfix_main_config}
  328. echo "                   reject_rbl_client bl.spamcop.net," >> ${postfix_main_config}
  329. echo "                   reject_rbl_client dnsbl.sorbs.net=127.0.0.2," >> ${postfix_main_config}
  330. echo "                   reject_rbl_client dnsbl.sorbs.net=127.0.0.3," >> ${postfix_main_config}
  331. echo "                   reject_rbl_client dnsbl.sorbs.net=127.0.0.4," >> ${postfix_main_config}
  332. echo "                   reject_rbl_client dnsbl.sorbs.net=127.0.0.5," >> ${postfix_main_config}
  333. echo "                   reject_rbl_client dnsbl.sorbs.net=127.0.0.7," >> ${postfix_main_config}
  334. echo "                   reject_rbl_client dnsbl.sorbs.net=127.0.0.9," >> ${postfix_main_config}
  335. echo "                   reject_rbl_client dnsbl.sorbs.net=127.0.0.11," >> ${postfix_main_config}
  336. echo "                   reject_rbl_client dnsbl.sorbs.net=127.0.0.12," >> ${postfix_main_config}
  337. echo "                   warn_if_reject reject_rhsbl_sender dsn.rfc-ignorant.org," >> ${postfix_main_config}
  338. echo "                   warn_if_reject reject_rhsbl_sender abuse.rfc-ignorant.org," >> ${postfix_main_config}
  339. echo "                   warn_if_reject reject_rhsbl_sender whois.rfc-ignorant.org," >> ${postfix_main_config}
  340. echo "                   warn_if_reject reject_rhsbl_sender bogusmx.rfc-ignorant.org," >> ${postfix_main_config}
  341. echo "                   warn_if_reject reject_rhsbl_sender postmaster.rfc-ignorant.org" >> ${postfix_main_config}
  342. echo "smtpd_sender_restrictions      = permit_mynetworks," >> ${postfix_main_config}
  343. echo "                           permit_sasl_authenticated," >> ${postfix_main_config}
  344. echo "                           reject_unauth_pipelining," >> ${postfix_main_config}
  345. echo "                           reject_non_fqdn_sender," >> ${postfix_main_config}
  346. echo "                           reject_unknown_sender_domain" >> ${postfix_main_config}
  347. echo "smtpd_data_restrictions        = reject_unauth_pipelining," >> ${postfix_main_config}
  348. echo "                           reject_multi_recipient_bounce" >> ${postfix_main_config}
  349. echo "#########################################################################" >> ${postfix_main_config}
  350. echo "# TLS CONFIGURATION" >> ${postfix_main_config}
  351. echo "#########################################################################" >> ${postfix_main_config}
  352. echo "#smtp_tls_CAfile                   = /etc/pki/tls/certs/cert.pem" >> ${postfix_main_config}
  353. echo "#smtp_tls_cert_file                = /etc/pki/tls/certs/myserver.example.com.crt" >> ${postfix_main_config}
  354. echo "#smtp_tls_key_file                 = /etc/pki/tls/private/myserver.example.com.key" >> ${postfix_main_config}
  355. echo "##Postfix 2.5 or greater must use:##" >> ${postfix_main_config}
  356. echo "##smtp_tls_session_cache_database  = btree:\$data_directory/smtp_tls_session_cache" >> ${postfix_main_config}
  357. echo "#smtp_tls_session_cache_database   = btree:/var/spool/postfix/smtp_tls_session_cache" >> ${postfix_main_config}
  358. echo "#smtp_tls_security_level = may" >> ${postfix_main_config}
  359. echo "#smtpd_tls_CAfile                  = /etc/pki/tls/certs/cert.pem" >> ${postfix_main_config}
  360. echo "#smtpd_tls_cert_file               = /etc/pki/tls/certs/myserver.example.com.crt" >> ${postfix_main_config}
  361. echo "#smtpd_tls_key_file                = /etc/pki/tls/private/myserver.example.com.key" >> ${postfix_main_config}
  362. echo "##Postfix 2.5 or greater must use:##" >> ${postfix_main_config}
  363. echo "##smtpd_tls_session_cache_database = btree:\$data_directory/smtpd_tls_session_cache" >> ${postfix_main_config}
  364. echo "#smtpd_tls_session_cache_database  = btree:/var/spool/postfix/smtpd_tls_session_cache" >> ${postfix_main_config}
  365. echo "#smtpd_tls_dh1024_param_file       = \$config_directory/dh_1024.pem" >> ${postfix_main_config}
  366. echo "#smtpd_tls_dh512_param_file        = \$config_directory/dh_512.pem" >> ${postfix_main_config}
  367. echo "#smtpd_tls_security_level          = may" >> ${postfix_main_config}
  368. echo "#smtpd_tls_received_header         = yes" >> ${postfix_main_config}
  369. echo "#smtpd_tls_ask_ccert               = yes" >> ${postfix_main_config}
  370. echo "#smtpd_tls_loglevel                = 1" >> ${postfix_main_config}
  371. echo "#tls_random_source                 = dev:/dev/urandom" >> ${postfix_main_config}
  372. echo "#########################################################################" >> ${postfix_main_config}
  373. echo "# SPECIAL CONFIGURATION EXTRAS" >> ${postfix_main_config}
  374. echo "#########################################################################" >> ${postfix_main_config}
  375. echo "#default_privs        = nobody" >> ${postfix_main_config}
  376. echo "#proxy_interfaces     = 1.2.3.4" >> ${postfix_main_config}
  377. echo "#relay_domains        = \$mydestination" >> ${postfix_main_config}
  378. echo "#relayhost            = [gateway.my.domain]" >> ${postfix_main_config}
  379. echo "#relayhost            = [an.ip.add.ress]" >> ${postfix_main_config}
  380. echo "#relay_recipient_maps = hash:/etc/postfix/relay_recipients" >> ${postfix_main_config}
  381. echo "#in_flow_delay        = 1s" >> ${postfix_main_config}
  382. echo "#recipient_delimiter  = +" >> ${postfix_main_config}
  383. echo "#home_mailbox         = Maildir/" >> ${postfix_main_config}
  384. echo "#mail_spool_directory = /var/spool/mail" >> ${postfix_main_config}
  385. echo "#mailbox_command      = /some/where/procmail" >> ${postfix_main_config}
  386. echo "#mailbox_transport    = cyrus" >> ${postfix_main_config}
  387. echo "#fallback_transport   = lmtp:unix:/var/lib/imap/socket/lmtp" >> ${postfix_main_config}
  388. echo "#luser_relay          = \$user@other.host" >> ${postfix_main_config}
  389. echo "#header_checks        = regexp:/etc/postfix/header_checks" >> ${postfix_main_config}
  390. echo "#fast_flush_domains   = \$relay_domains" >> ${postfix_main_config}
  391. echo "#smtpd_banner         = \$myhostname ESMTP $mail_name ($mail_version)" >> ${postfix_main_config}
  392. echo "#local_destination_concurrency_limit   = 2" >> ${postfix_main_config}
  393. echo "#default_destination_concurrency_limit = 20" >> ${postfix_main_config}
  394. echo "#########################################################################" >> ${postfix_main_config}
  395. echo "# DEBUG CONFIGURATION" >> ${postfix_main_config}
  396. echo "#########################################################################" >> ${postfix_main_config}
  397. echo "#debug_peer_list = 127.0.0.1" >> ${postfix_main_config}
  398. echo "#debug_peer_list = some.domain" >> ${postfix_main_config}
  399. echo "debugger_command =" >> ${postfix_main_config}
  400. echo "   PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin" >> ${postfix_main_config}
  401. echo "   xxgdb $daemon_directory/\$process_name \$process_id & sleep 5" >> ${postfix_main_config}
  402. echo "# debugger_command =" >> ${postfix_main_config}
  403. echo "# PATH=/bin:/usr/bin:/usr/local/bin; export PATH; (echo cont;" >> ${postfix_main_config}
  404. echo "# echo where) | gdb \$daemon_directory/\$process_name \$process_id 2>&1" >> ${postfix_main_config}
  405. echo "# >\$config_directory/\$process_name.\$process_id.log & sleep 5" >> ${postfix_main_config}
  406. echo "#" >> ${postfix_main_config}
  407. echo "# debugger_command =" >> ${postfix_main_config}
  408. echo "# PATH=/bin:/usr/bin:/sbin:/usr/sbin; export PATH; screen" >> ${postfix_main_config}
  409. echo "# -dmS \$process_name gdb \$daemon_directory/\$process_name" >> ${postfix_main_config}
  410. echo "# \$process_id & sleep 1" >> ${postfix_main_config}
  411. echo "#########################################################################" >> ${postfix_main_config}
  412. echo "# ZPANEL CONFIGURATION" >> ${postfix_main_config}
  413. echo "#########################################################################" >> ${postfix_main_config}
  414. echo "#transport_maps                = mysql:${mysql_virtual_transport}" >> ${postfix_main_config}
  415. echo "#relay_domains                 = mysql:${mysql_relay_domains_maps}" >> ${postfix_main_config}
  416. echo "virtual_alias_maps             = mysql:${mysql_virtual_alias_maps}" >> ${postfix_main_config}
  417. echo "virtual_mailbox_domains        = mysql:${mysql_virtual_domains_maps}" >> ${postfix_main_config}
  418. echo "virtual_mailbox_maps           = mysql:${mysql_virtual_mailbox_maps}" >> ${postfix_main_config}
  419. echo "virtual_mailbox_limit          = 51200000" >> ${postfix_main_config}
  420. echo "virtual_minimum_uid            = 5000" >> ${postfix_main_config}
  421. echo "virtual_uid_maps               = static:5000" >> ${postfix_main_config}
  422. echo "virtual_gid_maps               = static:5000" >> ${postfix_main_config}
  423. echo "virtual_mailbox_base           = /var/zpanel/vmail" >> ${postfix_main_config}
  424. echo "virtual_transport              = virtual" >> ${postfix_main_config}
  425. echo "virtual_create_maildirsize     = yes" >> ${postfix_main_config}
  426. echo "virtual_mailbox_extended       = yes" >> ${postfix_main_config}
  427. echo "virtual_mailbox_limit_maps     = mysql:${mysql_virtual_mailbox_limit_maps}" >> ${postfix_main_config}
  428. echo "virtual_mailbox_limit_override = yes" >> ${postfix_main_config}
  429. echo "virtual_maildir_limit_message  = Sorry, the user's maildir has no space available in their inbox." >> ${postfix_main_config}
  430. echo "virtual_overquota_bounce       = yes" >> ${postfix_main_config}
  431. echo "local_transport                = virtual" >> ${postfix_main_config}
  432. echo "dovecot_destination_recipient_limit = 1" >> ${postfix_main_config}
  433.  
  434. # Dovecot Conf
  435. echo "protocols = imap imaps pop3 pop3s" > ${dovecot_config}
  436. echo "log_timestamp = '%Y-%m-%d %H:%M:%S'" >> ${dovecot_config}
  437. echo "mail_location = maildir:/var/zpanel/vmail/%d/%n" >> ${dovecot_config}
  438. echo "protocol pop3 {" >> ${dovecot_config}
  439. echo "    pop3_uidl_format = %08Xu%08Xv" >> ${dovecot_config}
  440. echo "}" >> ${dovecot_config}
  441. echo "" >> ${dovecot_config}
  442. echo "auth default {" >> ${dovecot_config}
  443. echo "    mechanisms = plain login" >> ${dovecot_config}
  444. echo "    user = root" >> ${dovecot_config}
  445. echo "" >> ${dovecot_config}
  446. echo "    passdb sql {" >> ${dovecot_config}
  447. echo "        args = ${dovecot_sql_config}" >> ${dovecot_config}
  448. echo "    }" >> ${dovecot_config}
  449. echo "" >> ${dovecot_config}
  450. echo "    userdb sql {" >> ${dovecot_config}
  451. echo "        args = ${dovecot_sql_config}" >> ${dovecot_config}
  452. echo "    }" >> ${dovecot_config}
  453. echo "" >> ${dovecot_config}
  454. echo "    socket listen {" >> ${dovecot_config}
  455. echo "        client {" >> ${dovecot_config}
  456. echo "            path = /var/spool/postfix/private/auth" >> ${dovecot_config}
  457. echo "            mode = 0660" >> ${dovecot_config}
  458. echo "            user = postfix" >> ${dovecot_config}
  459. echo "            group = postfix" >> ${dovecot_config}
  460. echo "        }" >> ${dovecot_config}
  461. echo "    }" >> ${dovecot_config}
  462. echo "}" >> ${dovecot_config}
  463. echo "plugin {" >> ${dovecot_config}
  464. echo "  #quota = maildir:storage=10240:messages=1000" >> ${dovecot_config}
  465. echo "  #acl  = vfile:/etc/dovecot/acls" >> ${dovecot_config}
  466. echo "  trash = ${dovecot_trash_config}" >> ${dovecot_config}
  467. echo "}" >> ${dovecot_config}
  468.  
  469. # Postfix and dovecot sql mappings
  470. touch ${dovecot_sql_config}
  471. chmod 777 ${dovecot_sql_config}
  472. echo "driver = mysql" > ${dovecot_sql_config}
  473. echo "connect = host=127.0.0.1 dbname=zpanel_postfix user=root password=${password}" >> ${dovecot_sql_config}
  474. echo "default_pass_scheme = PLAIN" >> ${dovecot_sql_config}
  475. echo "password_query = SELECT password FROM mailbox WHERE username = '%u'" >> ${dovecot_sql_config}
  476. echo "user_query = SELECT maildir, 5000 AS uid, 5000 AS gid FROM mailbox WHERE username = '%u' AND active = '1'" >> ${dovecot_sql_config}
  477.  
  478. touch ${dovecot_trash_config}
  479. chmod 777 ${dovecot_trash_config}
  480. echo "1 Spam" > ${dovecot_trash_config}
  481. echo "2 Trash" >> ${dovecot_trash_config}
  482. echo "3 Junk" >> ${dovecot_trash_config}
  483.  
  484. touch ${mysql_relay_domains_maps}
  485. chmod 777 ${mysql_relay_domains_maps}
  486. echo "user = root" > ${mysql_relay_domains_maps}
  487. echo "password = ${password}" >> ${mysql_relay_domains_maps}
  488. echo "hosts = 127.0.0.1" >> ${mysql_relay_domains_maps}
  489. echo "dbname = zpanel_postfix" >> ${mysql_relay_domains_maps}
  490. echo "table = domain" >> ${mysql_relay_domains_maps}
  491. echo "select_field = domain" >> ${mysql_relay_domains_maps}
  492. echo "where_field = domain" >> ${mysql_relay_domains_maps}
  493. echo "additional_conditions = and backupmx = '1'" >> ${mysql_relay_domains_maps}
  494.  
  495. touch ${mysql_virtual_alias_maps}
  496. chmod 777 ${mysql_virtual_alias_maps}
  497. echo "user = root" > ${mysql_virtual_alias_maps}
  498. echo "password = ${password}" >> ${mysql_virtual_alias_maps}
  499. echo "hosts = 127.0.0.1" >> ${mysql_virtual_alias_maps}
  500. echo "dbname = zpanel_postfix" >> ${mysql_virtual_alias_maps}
  501. echo "table = alias" >> ${mysql_virtual_alias_maps}
  502. echo "select_field = goto" >> ${mysql_virtual_alias_maps}
  503. echo "where_field = address" >> ${mysql_virtual_alias_maps}
  504.  
  505. touch ${mysql_virtual_domains_maps}
  506. chmod 777 ${mysql_virtual_domains_maps}
  507. echo "user = root" > ${mysql_virtual_domains_maps}
  508. echo "password = ${password}" >> ${mysql_virtual_domains_maps}
  509. echo "hosts = 127.0.0.1" >> ${mysql_virtual_domains_maps}
  510. echo "dbname = zpanel_postfix" >> ${mysql_virtual_domains_maps}
  511. echo "table = domain" >> ${mysql_virtual_domains_maps}
  512. echo "select_field = domain" >> ${mysql_virtual_domains_maps}
  513. echo "where_field = domain" >> ${mysql_virtual_domains_maps}
  514. echo "#additional_conditions = and backupmx = '0' and active = '1'" >> ${mysql_virtual_domains_maps}
  515.  
  516. touch ${mysql_virtual_mailbox_limit_maps}
  517. chmod 777 ${mysql_virtual_mailbox_limit_maps}
  518. echo "user = root" > ${mysql_virtual_mailbox_limit_maps}
  519. echo "password = ${password}" >> ${mysql_virtual_mailbox_limit_maps}
  520. echo "hosts = 127.0.0.1" >> ${mysql_virtual_mailbox_limit_maps}
  521. echo "dbname = zpanel_postfix" >> ${mysql_virtual_mailbox_limit_maps}
  522. echo "table = mailbox" >> ${mysql_virtual_mailbox_limit_maps}
  523. echo "select_field = quota" >> ${mysql_virtual_mailbox_limit_maps}
  524. echo "where_field = username" >> ${mysql_virtual_mailbox_limit_maps}
  525. echo "#additional_conditions = and active = '1'" >> ${mysql_virtual_mailbox_limit_maps}
  526.  
  527. touch ${mysql_virtual_mailbox_maps}
  528. chmod 777 ${mysql_virtual_mailbox_maps}
  529. echo "user = root" > ${mysql_virtual_mailbox_maps}
  530. echo "password = ${password}" >> ${mysql_virtual_mailbox_maps}
  531. echo "hosts = 127.0.0.1" >> ${mysql_virtual_mailbox_maps}
  532. echo "dbname = zpanel_postfix" >> ${mysql_virtual_mailbox_maps}
  533. echo "table = mailbox" >> ${mysql_virtual_mailbox_maps}
  534. echo "select_field = maildir" >> ${mysql_virtual_mailbox_maps}
  535. echo "where_field = username" >> ${mysql_virtual_mailbox_maps}
  536. echo "#additional_conditions = and active = '1'" >> ${mysql_virtual_mailbox_maps}
  537.  
  538. touch ${mysql_virtual_transport}
  539. chmod 777 ${mysql_virtual_transport}
  540. echo "user = root" > ${mysql_virtual_transport}
  541. echo "password = ${password}" >> ${mysql_virtual_transport}
  542. echo "hosts = 127.0.0.1" >> ${mysql_virtual_transport}
  543. echo "dbname = zpanel_postfix" >> ${mysql_virtual_transport}
  544. echo "table = domain" >> ${mysql_virtual_transport}
  545. echo "select_field = transport" >> ${mysql_virtual_transport}
  546. echo "where_field = domain" >> ${mysql_virtual_transport}
  547.  
  548. # Roundcube Webmail Config
  549. echo "<?php" > /etc/zpanel/apps/webmail/config/db.inc.php
  550. echo "\$rcmail_config = array();" >> /etc/zpanel/apps/webmail/config/db.inc.php
  551. echo "\$rcmail_config['db_dsnw'] = 'mysql://root:${password}@localhost/zpanel_roundcube';" >> /etc/zpanel/apps/webmail/config/db.inc.php
  552. echo "\$rcmail_config['db_dsnr'] = '';" >> /etc/zpanel/apps/webmail/config/db.inc.php
  553. echo "\$rcmail_config['db_max_length'] = 512000;" >> /etc/zpanel/apps/webmail/config/db.inc.php
  554. echo "\$rcmail_config['db_persistent'] = FALSE;" >> /etc/zpanel/apps/webmail/config/db.inc.php
  555. echo "\$rcmail_config['db_table_users'] = 'users';" >> /etc/zpanel/apps/webmail/config/db.inc.php
  556. echo "\$rcmail_config['db_table_identities'] = 'identities';" >> /etc/zpanel/apps/webmail/config/db.inc.php
  557. echo "\$rcmail_config['db_table_contacts'] = 'contacts';" >> /etc/zpanel/apps/webmail/config/db.inc.php
  558. echo "\$rcmail_config['db_table_session'] = 'session';" >> /etc/zpanel/apps/webmail/config/db.inc.php
  559. echo "\$rcmail_config['db_table_cache'] = 'cache';" >> /etc/zpanel/apps/webmail/config/db.inc.php
  560. echo "\$rcmail_config['db_table_messages'] = 'messages';" >> /etc/zpanel/apps/webmail/config/db.inc.php
  561. echo "\$rcmail_config['db_sequence_users'] = 'user_ids';" >> /etc/zpanel/apps/webmail/config/db.inc.php
  562. echo "\$rcmail_config['db_sequence_identities'] = 'identity_ids';" >> /etc/zpanel/apps/webmail/config/db.inc.php
  563. echo "\$rcmail_config['db_sequence_contacts'] = 'contact_ids';" >> /etc/zpanel/apps/webmail/config/db.inc.php
  564. echo "\$rcmail_config['db_sequence_cache'] = 'cache_ids';" >> /etc/zpanel/apps/webmail/config/db.inc.php
  565. echo "\$rcmail_config['db_sequence_messages'] = 'message_ids';" >> /etc/zpanel/apps/webmail/config/db.inc.php
  566. echo "?>" >> /etc/zpanel/apps/webmail/config/db.inc.php
  567.  
  568. chgrp postfix /etc/postfix/mysql_*.cf
  569. chmod 777 /etc/postfix/mysql_*.cf
  570.  
  571. # Set the correct service names in the database for this distrubion...
  572. /etc/zpanel/lib/dev/setso --set -q lsn_apache apache2
  573. /etc/zpanel/lib/dev/setso --set -q lsn_proftpd proftpd
  574. /etc/zpanel/lib/dev/setso --set -q cron_file /var/spool/cron/crontabs/www-data
  575.  
  576. /etc/init.d/postfix restart
  577. /etc/init.d/dovecot restart
  578. /etc/init.d/apache2 restart
  579.  
  580. ################################################################################################
  581. # END Configure Postfix Mail Server ############################################################
  582. ################################################################################################
  583.  
  584. echo "=========================================================="
  585. echo "ZPanel has now been installed!"
  586. echo " "
  587. echo "IMPORTANT: Ensure you make a note of these settings"
  588. echo "           for future reference and to access the"
  589. echo "           control panel for the first time..."
  590. echo " "
  591. echo "           NEW MYSQL ROOT ACCOUNT"
  592. echo "           =============================================="
  593. echo "           PASSWORD: ${password}"
  594. echo " "
  595. echo "           ZPANEL ADMIN ACCOUNT LOGIN"
  596. echo "           =============================================="
  597. echo "           CONTROL PANEL URL: http://${domain}"
  598. echo "           USERNAME: zadmin"
  599. echo "           PASSWORD: ${zpassword}"
  600. echo ""
  601.  
  602.  
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top