设为首页 收藏本站
查看: 699|回复: 0

Three_install postifx is shell

[复制链接]

尚未签到

发表于 2018-8-26 07:33:10 | 显示全部楼层 |阅读模式
  #!/bin/bash
  LANG=C
  # dovecot-2.2.5.tar.gz
  # courier-authlib-0.63.0.tar.bz2
  # extman-1.1.tar.gz
  # extmail-1.2.tar.gz
  # Unix-Syslog-1.1.tar.gz
  # DBI-1.607.tar.gz
  # DBD-mysql-4.011.tar.gz
  # GD-2.41.tar.gz
  # File-Tail-0.99.3.tar.gz
  INST_DIR=/usr/src
  sed -i '/SELINUX=/s/SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
  setenforce 0
  iptables -F
  service iptables save
  chkconfig iptables off
  yum clean all;yum list
  grep postfix /etc/rc.local || echo '/usr/sbin/postfix start' >> /etc/rc.local
  ldconfig
  useradd -M -s /sbin/nologin dovecot
  useradd -M -s /sbin/nologin dovenull
  yum  -y install pam-devel
  cd $INST_DIR
  tar zxf dovecot-2.2.5.tar.gz -C /usr/src
  cd /usr/src/dovecot-2.2.5/
  ./configure --sysconfdir=/etc --with-mysql --with-pam
  make
  make install
  /bin/cp -rf doc/dovecot-initd.sh /etc/init.d/dovecot
  chmod +x /etc/init.d/dovecot
  chkconfig --add dovecot
  /bin/cp -rpf doc/example-config/* /etc/dovecot/
  auth   requiredpam_nologin.so
  auth   includesystem-auth
  account   includesystem-auth
  session   includesystem-auth' > /etc/pam.d/dovecot
  chown -R postfix /var/lib/postfix
  postfix start
  chown -R postfix /var/spool/postfix/private/
  chown -R postfix /var/spool/postfix/public/
  chown -R :postdrop /var/spool/postfix/public/
  yum -y install libtool-ltdl-devel expect
  cd $INST_DIR
  tar jxf courier-authlib-0.63.0.tar.bz2 -C /usr/src/
  cd /usr/src/courier-authlib-0.63.0/
  ./configure --prefix=/usr/local/authd --without-stdheaderdir --with-mysql-libs=/usr/local/mysql/lib/mysql --with-mysql-includes=/usr/local/mysql/include/mysql --with-mailuser=postfix --with-mailgroup=postfix --without-authpam --without-authldap --without-authpgsql --without-authcustom --without-authpipe --without-authuserdb --without-authpwd --without-authshadow 2> $INST_DIR/authlib.error1
  make 2> $INST_DIR/authlib.error2
  make install 2> $INST_DIR/authlib.error3
  make install-configure 2> $INST_DIR/authlib.error4
  echo '/usr/local/authd/lib/courier-authlib' > /etc/ld.so.conf.d/courier-authlib.conf
  ldconfig
  /bin/cp -f /usr/src/courier-authlib-0.63.0/courier-authlib.sysvinit /etc/init.d/authd
  chmod +x /etc/init.d/authd
  chkconfig --add authd
  cd $INST_DIR
  tar zxf extman-1.1.tar.gz -C /usr/src/
  mysql -u root -p < /usr/src/extman-1.1/docs/extmail.sql
  mysql -u root -p < /usr/src/extman-1.1/docs/init.sql
  mkdir -p /mxdir/extmail.org/postmaster/Maildir/
  chown -R postfix:postfix /mxdir/
  cd  /usr/src/extman-1.1/docs
  cp mysql_virtual_*.cf  /etc/postfix/
  chown  -R  :postfix  /etc/postfix/mysql_virtual_*.cf
  chmod o-r  /etc/postfix/mysql_virtual_*.cf
  sed -i '76a myhostname  = mail.wgl.com' /etc/postfix/main.cf
  sed -i '84a mydomain  = wgl.com' /etc/postfix/main.cf
  sed -i '99a myorigin  =  $mydomain' /etc/postfix/main.cf
  sed -i '263a mynetworks  =  127.0.0.1' /etc/postfix/main.cf
  echo "smtpd_sasl_auth_enable  = yes
  smtpd_sasl_security_options  = noanonymous
  smtpd_recipient_restrictions  = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
  virtual_mailbox_base  =  /mxdir
  virtual_alias_maps  = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
  virtual_mailbox_maps  = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
  virtual_mailbox_domains  = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
  virtual_uid_maps  = static:1000
  virtual_gid_maps  = static:1000
  SYS_G_ABOOK_FILE_PATH = /usr/local/httpd/htdocs/extmail/globabook.cf
  alias_maps = hash:/etc/aliases" >> /etc/postfix/main.cf
  echo 'pwcheck_method:authdaemond
  authdaemond_path:/usr/local/authd/var/spool/authdaemon/socket' > /etc/sasl2/smtpd.conf
  chmod -R 755 /usr/local/authd/var/spool/authdaemon/
  FILE=/usr/local/authd/etc/authlib/authmysqlrc
  B=`find / -name mysql.sock`
  sed -i 's/mysql.example.com/localhost/' $FILE
  sed -i 's/admin/extmail/' $FILE
  sed -i 's/var\/mysql\/mysql.sock\//tmp\/mysql.sock/' $FILE
  sed -i '/MYSQL_DATABASE/s/mysql/extmail/' $FILE
  sed -i '/MYSQL_USER_TABLE/s/passwd/mailbox/' $FILE
  sed -i '/MYSQL_CRYPT_PWFIELD/s/crypt/password/' $FILE
  sed -i '/MYSQL_UID_FIELD/s/uid/uidnumber/' $FILE
  sed -i '/MYSQL_GID_FIELD/s/gid/gidnumber/' $FILE
  sed -i '/YSQL_LOGIN_FIELD/s/id/username/' $FILE
  sed -i "/MYSQL_HOME_FIELD/s/home/concat('\/mxdir\/',homedir)/" $FILE
  sed -i "150a MYSQL_MAILDIR_FIELD    concat('\/mxdir\/',maildir)" $FILE
  sed -i 's/\/var\/lib\/mysql\/mysql.sock/\/tmp\/mysql.sock/' $FILE
  AUTH=/usr/local/authd/etc/authlib/authdaemonrc
  sed -i '35a authmodulelist="authmysql"' $AUTH
  sed -i '35a authmodulelistorig="authmysql" ' $AUTH
  /etc/init.d/authd restart
  postfix stop &> /dev/null ; postfix start
  /etc/init.d/dovecot restart
  /etc/init.d/authd restart
  echo "mail_location  = maildir:/mxdir/%d/%n/Maildir" >> /etc/dovecot/conf.d/10-mail.conf
  cd  /etc/dovecot/conf.d/
  cp auth-sql.conf.ext  10-auth-sql.conf
  SQL=/etc/dovecot/dovecot-sql.conf.ext
  sed -i '70a connect  = host=localhost dbname=extmail user=extmail password=extmail ' $SQL
  sed -i  "116a password_query  =   SELECT username,password FROM mailbox WHERE username='%u'" $SQL
  sed -i '70a default_pass_scheme  = CRYPT' $SQL
  sed -i "125a user_query  = SELECT maildir,uidnumber,gidnumber FROM mailbox WHERE username='%u'" $SQL
  /etc/init.d/dovecot restart
  /usr/local/authd/sbin/authtest -s smtp postmaster@extmail.org extmail | grep succeeded  &> /dev/null&& echo "authlib 认证成功" || echo "authlib 认证失败"
  echo 'NameVirtualHost *:80
  
  ServerName mail.wgl.com
  DocumentRoot "/usr/local/httpd/htdocs/extmail/html"
  ScriptAlias /extmail/cgi/ /usr/local/httpd/htdocs/extmail/cgi/
  Alias /extmail  /usr/local/httpd/htdocs/extmail/html/
  ScriptAlias /extman/cgi/ /usr/local/httpd/htdocs/extman/cgi/
  Alias /extman /usr/local/httpd/htdocs/extman/html/
  SuexecUserGroup postfix postfix
  ' > /usr/local/httpd/conf/extra/httpd-vhosts.conf
  grep CharsetDefault /usr/local/httpd/conf/httpd.conf || echo 'CharsetDefault utf8' >> /usr/loca
  l/httpd/conf/httpd.conf
  /etc/init.d/httpd restart
  cd $INST_DIR
  tar -zxf extman-1.1.tar.gz -C /usr/src/
  mv extman-1.1 /usr/local/httpd/htdocs/extman
  chown -R postfix:postfix /usr/local/httpd/htdocs/extman/cgi/
  cd /usr/local/httpd/htdocs/extman/
  cp webman.cf.default webman.cf
  CONf=/usr/local/httpd/htdocs/extman/webman.cf
  sed -i 's/SYS_CONFIG.*/SYS_CONFIG  =  \/usr\/local\/httpd\/htdocs\/extman/' $CONf
  sed -i 's/SYS_LANGDIR.*/SYS_LANGDIR  =  \/usr\/local\/httpd\/htdocs\/extman\/lang/' $CONf
  sed -i 's/SYS_TEMPLDIR.*/SYS_TEMPLDIR  = \/usr\/local\/httpd\/htdocs\/extman\/html/' $CONf
  sed -i 's/SYS_MAILDIR_BASE.*/SYS_MAILDIR_BASE  =  \/mxdir/' $CONf
  sed -i 's/SYS_SESS_DIR.*/SYS_SESS_DIR  =  \/tmp\/extman/' $CONf
  sed -i '/SYS_CAPTCHA_ON/s/1/0/' $CONf
  sed -i '/SYS_MYSQL_USER/s/db_user/webmail/' $CONf
  sed -i '/SYS_MYSQL_PASS/s/db_pass/webmail/' $CONf
  sed -i '/SYS_MYSQL_SOCKET/s/\/var\/lib\/mysql\/mysql.sock/\/tmp\/mysql.sock/' $CONf
  mkdir -p /tmp/extman
  chown -R postfix:postfix /tmp/extman
  [ -f /var/lib/mysql/ ] || mkdir /var/lib/mysql ; ln -s /tmp/mysql.sock /var/lib/mysql/
  cd $INST_DIR
  tar -zxf extmail-1.2.tar.gz -C /usr/src/
  mv /usr/src/extmail-1.2 /usr/local/httpd/htdocs/extmail
  cd /usr/local/httpd/htdocs/extmail/
  cp webmail.cf.default webmail.cf
  chown -R postfix:postfix cgi/
  CONF=/usr/local/httpd/htdocs/extmail/webmail.cf
  sed -i 's/SYS_CONFIG.*/SYS_CONFIG  =  \/usr\/local\/httpd\/htdocs\/extmail/' $CONF
  sed -i 's/SYS_LANGDIR.*/SYS_LANGDIR  =  \/usr\/local\/httpd\/htdocs\/extmail\/lang/' $CONF
  sed -i 's/SYS_TEMPLDIR.*/SYS_TEMPLDIR  = \/usr\/local\/httpd\/htdocs\/extmail\/html/' $CONF
  sed -i 's/SYS_MAILDIR_BASE.*/SYS_MAILDIR_BASE  =  \/mxdir/' $CONF
  sed -i 's/SYS_SESS_DIR.*/SYS_SESS_DIR  =  \/tmp\/extman/' $CONF
  sed -i '/SYS_CAPTCHA_ON/s/1/0/' $CONF
  sed -i '/SYS_MYSQL_USER/s/db_user/extmail/' $CONF
  sed -i '/SYS_MYSQL_PASS/s/db_pass/extmail/' $CONF
  sed -i '/SYS_MYSQL_SOCKET/s/\/var\/lib\/mysql\/mysql.sock/\/tmp\/mysql.sock/' $CONF
  sed -i '/SYS_AUTHLIB_SOCKET/s/SYS.*/SYS_AUTHLIB_SOCKET  =  \/usr\/local\/authd\/var\/spool\/authdaemon\/socket/' $CONF
  sed -i '/SYS_G_ABOOK_FILE_PATH/s/SYS.*/SYS_G_ABOOK_FILE_PATH  =  \/usr\/local\/httpd\/htdocs\/extmail\/globabook.cf/' $CONF
  cd $INST_DIR
  tar zxf Unix-Syslog-1.1.tar.gz -C /usr/src/
  tar zxf DBI-1.607.tar.gz -C /usr/src/
  tar zxf DBD-mysql-4.011.tar.gz -C /usr/src/
  tar zxf GD-2.41.tar.gz -C /usr/src/
  tar zxf File-Tail-0.99.3.tar.gz -C /usr/src/
  export LANG='zh_CN.UTF-8'
  cd /usr/src/Unix-Syslog-1.1/
  perl Makefile.PL 2> $INST_DIR/Unix-Syslog.error
  make 2>> $INST_DIR/Unix-Syslog.error
  make install 2>> $INST_DIR/Unix-Syslog.error
  cd /usr/src/DBI-1.607/
  perl Makefile.PL 2> $INST_DIR/DBI.error
  make 2>> $INST_DIR/DBI.error
  make install 2>> $INST_DIR/DBI.error
  cd /usr/src/DBD-mysql-4.011
  perl Makefile.PL 2> $INST_DIR/DBD-mysql.error
  make 2>> $INST_DIR/DBD-mysql.error
  make install 2>> $INST_DIR/DBD-mysql.error
  cd /usr/src/GD-2.41
  perl Makefile.PL 2> $INST_DIR/DBD-mysql.error
  make 2>> $INST_DIR/DBD-mysql.error
  make install 2>> $INST_DIR/DBD-mysql.error
  cd /usr/src/File-Tail-0.99.3
  perl Makefile.PL ; make && make install
  yum -y install rrdtool rrdtool-devel rrdtool-perl
  yum -y install gd-devel
  cd $INST_DIR
  tar -zxf extman-1.1.tar.gz -C /usr/src/
  /bin/cp -rf /usr/src/extman-1.1/addon/mailgraph_ext/ /usr/local/
  /bin/cp -f /usr/local/mailgraph_ext/mailgraph-init /etc/init.d/mailgraphd
  chkconfig --add mailgraphd
  /etc/init.d/mailgraphd restart
  pgrep -l cmdserver || /usr/local/httpd/htdocs/extman/daemon/cmdserver -d
  grep cmdserver /etc/rc.local || echo '/usr/local/httpd/htdocs/extman/daemon/cmdserver -d' >> /etc/rc.local
  echo "数据库帐号/密码:extmail/extmail
  webman/extman
  邮箱帐号/密码:postmaster@extmail.org/extmail
  管理帐号/密码:root@extmail.org/extmail*123*

  登陆mysql对extmail授权:grant all privileges on extmail.* to 'extmail'@'localhost'>
  对extweb授权: grant all privileges on extmail.* to 'webmail'@'localhost'>  echo "查看所有邮箱用户:  select * from extmail.mailbox\G;"


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-556546-1-1.html 上篇帖子: shell脚本命令 下篇帖子: shell基本用法介绍
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表