Forráskód Böngészése

Fix Let's Encrypt

lj2007331 8 éve
szülő
commit
4915b2fc98
4 módosított fájl, 67 hozzáadás és 37 törlés
  1. 19 7
      addons.sh
  2. 2 3
      config/index.html
  3. 2 3
      config/index_cn.html
  4. 44 24
      vhost.sh

+ 19 - 7
addons.sh

@@ -124,12 +124,23 @@ EOF
   fi
 
   pushd ${oneinstack_dir}/src
-  src_url=https://dl.eff.org/certbot-auto && Download_src
-  /bin/mv certbot-auto /usr/local/bin/
-  chmod +x /usr/local/bin/certbot-auto
-  certbot-auto -n
+  if [ ! -e "/usr/bin/pip" ]; then
+    src_url=http://mirrors.linuxeye.com/oneinstack/src/pip-9.0.1.tar.gz && Download_src
+    tar xzf pip-9.0.1.tar.gz
+    pushd pip-9.0.1
+    python setup.py install
+    popd
+    rm -rf pip-9.0.1
+  fi
+  if [ ! -e "~/.pip/pip.conf" ] ;then
+    # get the IP information
+    PUBLIC_IPADDR=$(../include/get_public_ipaddr.py)
+    IPADDR_COUNTRY=$(../include/get_ipaddr_state.py $PUBLIC_IPADDR | awk '{print $1}')
+    [ "$IPADDR_COUNTRY"x != "CN"x ] && { mkdir ~/.pip; echo -e "[global]\nindex-url = https://pypi.tuna.tsinghua.edu.cn/simple" > ~/.pip/pip.conf; }
+  fi
+  pip install certbot
   popd
-  if [ -e "/root/.local/share/letsencrypt/bin/letsencrypt" ] && certbot-auto -h | grep '\-\-standalone' > /dev/null ; then
+  if [ -e "/usr/bin/certbot" ]; then
     echo; echo "${CSUCCESS}Let's Encrypt client installed successfully! ${CEND}"
   else
     echo; echo "${CFAILURE}Let's Encrypt client install failed, Please try again! ${CEND}"
@@ -137,9 +148,10 @@ EOF
 }
 
 Uninstall_letsencrypt() {
-  rm -rf /usr/local/bin/cerbot-auto /etc/letsencrypt /var/log/letsencrypt /var/lib/letsencrypt
+  pip uninstall certbot
+  rm -rf /etc/letsencrypt /var/log/letsencrypt /var/lib/letsencrypt
   [ "${OS}" == "CentOS" ] && Cron_file=/var/spool/cron/root || Cron_file=/var/spool/cron/crontabs/root
-  sed -i '/certbot-auto/d' ${Cron_file}
+  sed -i '/certbot/d' ${Cron_file}
   echo; echo "${CMSG}Let's Encrypt client uninstall completed${CEND}";
 }
 

+ 2 - 3
config/index.html

@@ -28,9 +28,8 @@ font-family:"Microsoft YaHei",sans-serif;
 <p><b>Create FTP virtual running script:</b>&nbsp;&nbsp;<font color="#008000">./pureftpd_vhost.sh</font></p>
 <p><b>For feedback, questions, and to follow the progress of the project:&nbsp;&nbsp;</b> <a target="_blank" class="links" href="https://oneinstack.com">https://oneinstack.com</a></p>
 <p><b>Author email:&nbsp;&nbsp;</b><a class="email" href="mailto:lj2007331@gmail.com">lj2007331@gmail.com</a></p>
-<p><b>Donate:</b></p>
-<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PayPal:&nbsp;&nbsp;lj2007331@gmail.com</p>
-<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AliPay:&nbsp;&nbsp;lj2007331@gmail.com</p>
+<p><b>Donate:</b>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://paypal.me/yeho" target="_blank"><img src="https://img.shields.io/badge/Paypal-donate-green.svg" alt="" /></a> <a href="https://static.oneinstack.com/images/alipay.png" target="_blank"><img src="https://img.shields.io/badge/Alipay-donate-green.svg" alt="" /></a> <a href="https://static.oneinstack.com/images/weixin.png" target="_blank"><img src="https://img.shields.io/badge/Wechat-donate-green.svg" /></a></p>
+<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Paypal:&nbsp;&nbsp;lj2007331@gmail.com &nbsp;&nbsp;Alipay:&nbsp;&nbsp;lj2007331@gmail.com</p>
 <div align="center"><iframe src="https://blog.linuxeye.com/ad_buttom.html" width="475" frameborder="0" scrolling="no"></iframe></div>
 <div align="center"><h3><a href="https://oneinstack.com" target="_blank">OneinStack</a> by <a href="https://blog.linuxeye.com/" target="_blank">LinuxEye</a></h3></div>
 </div>

+ 2 - 3
config/index_cn.html

@@ -29,9 +29,8 @@ font-family:微软雅黑,sans-serif;
 <p><b>Github 项目地址:</b>&nbsp;&nbsp;<a target="_blank" class="links" href="https://github.com/lj2007331/oneinstack">https://github.com/lj2007331/oneinstack</a></p>
 <p><b>OneinStack 官网:</b>&nbsp;&nbsp;<a target="_blank" class="links" href="https://oneinstack.com">https://oneinstack.com</a></p>
 <p><b>QQ 群:</b>&nbsp;&nbsp;558540514(付费千人群) 535783209(新)</p>
-<p><b>赞助我们:</b></p>
-<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;支付宝:&nbsp;&nbsp;lj2007331@gmail.com</p>
-<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PayPal:&nbsp;&nbsp;lj2007331@gmail.com</p>
+<p><b>赞助我们:</b>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://paypal.me/yeho" target="_blank"><img src="https://img.shields.io/badge/Paypal-donate-green.svg" alt="" /></a> <a href="https://static.oneinstack.com/images/alipay.png" target="_blank"><img src="https://img.shields.io/badge/%E6%94%AF%E4%BB%98%E5%AE%9D-%E5%90%91TA%E6%8D%90%E5%8A%A9-green.svg" alt="" /></a> <a href="https://static.oneinstack.com/images/weixin.png" target="_blank"><img src="https://img.shields.io/badge/%E5%BE%AE%E4%BF%A1-%E5%90%91TA%E6%8D%90%E5%8A%A9-green.svg" /></a></p>
+<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Paypal:&nbsp;&nbsp;lj2007331@gmail.com &nbsp;&nbsp;支付宝:&nbsp;&nbsp;lj2007331@gmail.com</p>
 <div align="center"><iframe src="https://blog.linuxeye.com/ad_buttom.html" width="475" frameborder="0" scrolling="no"></iframe></div>
 <div align="center"><h3><a href="https://oneinstack.com" target="_blank">OneinStack</a> by <a href="https://blog.linuxeye.com/" target="_blank">Linux 运维笔记</a></h3></div>
 </div>

+ 44 - 24
vhost.sh

@@ -174,7 +174,7 @@ If you enter '.', the field will be left blank.
 }
 
 Create_SSL() {
-  if [ -e "/usr/local/bin/certbot-auto" -a -e "/root/.local/share/letsencrypt/bin/letsencrypt" ]; then
+  if [ -e "/usr/bin/certbot" ]; then
     while :; do echo
       read -p "Do you want to use a Let's Encrypt certificate? [y/n]: " letsencrypt_yn
       if [[ ! ${letsencrypt_yn} =~ ^[y,n]$ ]]; then
@@ -202,10 +202,30 @@ Create_SSL() {
           break
         fi
       done
+
       [ "${moredomainame_yn}" == 'y' ] && moredomainame_D="$(for D in ${moredomainame}; do echo -d ${D}; done)"
-      [ "${nginx_ssl_yn}" == 'y' ] && S=nginx
-      [ "${apache_ssl_yn}" == 'y' ] && S=httpd
-      certbot-auto certonly --standalone --agree-tos --email ${Admin_Email} -w ${vhostdir} -d ${domain} ${moredomainame_D} --pre-hook "service ${S} stop" --post-hook "service ${S} start"
+      if [ "${nginx_ssl_yn}" == 'y' ]; then 
+        [ ! -d ${web_install_dir}/conf/vhost ] && mkdir ${web_install_dir}/conf/vhost
+        echo "server {  server_name ${domain}${moredomainame};  root ${vhostdir};  access_log off; }" > ${web_install_dir}/conf/vhost/${domain}.conf
+        /etc/init.d/nginx reload > /dev/null
+      fi
+
+      if [ "${apache_ssl_yn}" == 'y' ]; then
+        [ ! -d ${apache_install_dir}/conf/vhost ] && mkdir ${apache_install_dir}/conf/vhost
+        cat > ${apache_install_dir}/conf/vhost/${domain}.conf << EOF
+<VirtualHost *:80>
+  ServerAdmin admin@example.com
+  DocumentRoot "${vhostdir}"
+  ServerName ${domain}
+  ${Apache_Domain_alias}
+  ErrorLog "/dev/null" common
+  CustomLog "/dev/null" common
+</VirtualHost>
+EOF
+        /etc/init.d/httpd restart > /dev/null
+      fi
+
+      certbot certonly --webroot --agree-tos --quiet --email ${Admin_Email} -w ${vhostdir} -d ${domain} ${moredomainame_D}
       if [ -s "/etc/letsencrypt/live/${domain}/cert.pem" ]; then
         [ -e "${PATH_SSL}/${domain}.crt" ] && rm -rf ${PATH_SSL}/${domain}.{crt,key}
         ln -s /etc/letsencrypt/live/${domain}/fullchain.pem ${PATH_SSL}/${domain}.crt
@@ -218,7 +238,7 @@ Create_SSL() {
           Cron_Command="/etc/init.d/httpd graceful"
         fi
         [ "${OS}" == "CentOS" ] && Cron_file=/var/spool/cron/root || Cron_file=/var/spool/cron/crontabs/root
-        [ -z "$(grep 'certbot-auto renew' ${Cron_file})" ] && echo "0 0 1 * * /usr/local/bin/certbot-auto renew;${Cron_Command}" >> $Cron_file
+        [ -z "$(grep 'certbot renew' ${Cron_file})" ] && echo "0 0 1 * * certbot renew;${Cron_Command}" >> $Cron_file
       else
         echo "${CFAILURE}Error: Let's Encrypt SSL certificate installation failed! ${CEND}"
         exit 1
@@ -276,6 +296,25 @@ Input_Add_domain() {
     fi
   done
 
+  while :; do echo
+    echo "Please input the directory for the domain:${domain} :"
+    read -p "(Default directory: ${wwwroot_dir}/${domain}): " vhostdir
+    if [ -n "${vhostdir}" -a -z "$(echo ${vhostdir} | grep '^/')" ]; then
+      echo "${CWARNING}input error! Press Enter to continue...${CEND}"
+    else
+      if [ -z "${vhostdir}" ]; then
+        vhostdir="${wwwroot_dir}/${domain}"
+        echo "Virtual Host Directory=${CMSG}${vhostdir}${CEND}"
+      fi
+      echo
+      echo "Create Virtul Host directory......"
+      mkdir -p ${vhostdir}
+      echo "set permissions of Virtual Host directory......"
+      chown -R ${run_user}.${run_user} ${vhostdir}
+      break
+    fi
+  done
+
   if [ -e "${web_install_dir}/conf/vhost/${domain}.conf" -o -e "${apache_install_dir}/conf/vhost/${domain}.conf" -o -e "${tomcat_install_dir}/conf/vhost/${domain}.xml" ]; then
     [ -e "${web_install_dir}/conf/vhost/${domain}.conf" ] && echo -e "${domain} in the Nginx/Tengine/OpenResty already exist! \nYou can delete ${CMSG}${web_install_dir}/conf/vhost/${domain}.conf${CEND} and re-create"
     [ -e "${apache_install_dir}/conf/vhost/${domain}.conf" ] && echo -e "${domain} in the Apache already exist! \nYou can delete ${CMSG}${apache_install_dir}/conf/vhost/${domain}.conf${CEND} and re-create"
@@ -332,25 +371,6 @@ Input_Add_domain() {
       fi
     done
 
-  while :; do echo
-    echo "Please input the directory for the domain:${domain} :"
-    read -p "(Default directory: ${wwwroot_dir}/${domain}): " vhostdir
-    if [ -n "${vhostdir}" -a -z "$(echo ${vhostdir} | grep '^/')" ]; then
-      echo "${CWARNING}input error! Press Enter to continue...${CEND}"
-    else
-      if [ -z "${vhostdir}" ]; then
-        vhostdir="${wwwroot_dir}/${domain}"
-        echo "Virtual Host Directory=${CMSG}${vhostdir}${CEND}"
-      fi
-      echo
-      echo "Create Virtul Host directory......"
-      mkdir -p ${vhostdir}
-      echo "set permissions of Virtual Host directory......"
-      chown -R ${run_user}.${run_user} ${vhostdir}
-      break
-    fi
-  done
-
     if [[ "$(${web_install_dir}/sbin/nginx -V 2>&1 | grep -Eo 'with-http_v2_module')" = 'with-http_v2_module' ]]; then
       LISTENOPT="443 ssl http2"
     else