Browse Source

Support Fedora and Fixed bug

lj2007331@gmail.com 6 years ago
parent
commit
13147ddc24

+ 1 - 1
README.md

@@ -1,6 +1,6 @@
 [![PayPal donate button](https://img.shields.io/badge/paypal-donate-green.svg)](https://paypal.me/yeho) [![支付宝捐助按钮](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)](https://static.oneinstack.com/images/alipay.png) [![微信捐助按钮](https://img.shields.io/badge/%E5%BE%AE%E4%BF%A1-%E5%90%91TA%E6%8D%90%E5%8A%A9-green.svg)](https://static.oneinstack.com/images/weixin.png)
 
-This script is written using the shell, in order to quickly deploy `LEMP`/`LAMP`/`LNMP`/`LNMPA`/`LTMP`(Linux, Nginx/Tengine/OpenResty, MySQL in a production environment/MariaDB/Percona, PHP, JAVA), applicable to CentOS 6 ~ 7(including redhat), Debian 6 ~ 9, Ubuntu 12 ~ 16 of 32 and 64.
+This script is written using the shell, in order to quickly deploy `LEMP`/`LAMP`/`LNMP`/`LNMPA`/`LTMP`(Linux, Nginx/Tengine/OpenResty, MySQL in a production environment/MariaDB/Percona, PHP, JAVA), applicable to CentOS 6 ~ 7(including redhat), Debian 6 ~ 9, Ubuntu 12 ~ 16, Fedora 27~28 of 32 and 64.
 
 Script properties:
 - Continually updated, Provide Shell Interaction and Autoinstall

+ 2 - 2
addons.sh

@@ -24,8 +24,8 @@ oneinstack_dir=$(dirname "`readlink -f $0`")
 pushd ${oneinstack_dir} > /dev/null
 
 # get the IP information
-PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
-IPADDR_COUNTRY=`./include/get_ipaddr_state.py $PUBLIC_IPADDR | awk '{print $1}'`
+PUBLIC_IPADDR=$(./include/get_public_ipaddr.py)
+IPADDR_COUNTRY=$(./include/get_ipaddr_state.py $PUBLIC_IPADDR)
 
 . ./versions.txt
 . ./options.conf

+ 1 - 0
include/check_os.sh

@@ -13,6 +13,7 @@ if [ -e /etc/redhat-release ]; then
   [ ! -e "$(which lsb_release)" ] && { yum -y install redhat-lsb-core; clear; }
   CentOS_ver=$(lsb_release -sr | awk -F. '{print $1}')
   [ "${CentOS_ver}" == '17' ] && CentOS_ver=7
+  [ "$(lsb_release -is)" == 'Fedora' ] && [ ${CentOS_ver} -ge 19 >/dev/null 2>&1 ] && { CentOS_ver=7; Fedora_ver=$(lsb_release -rs); }
 elif [ -n "$(grep 'Amazon Linux' /etc/issue)" ]; then
   OS=CentOS
   CentOS_ver=7

+ 2 - 2
include/get_ipaddr.py

@@ -11,7 +11,7 @@ def Get_local_ip():
   try:
     socket.setdefaulttimeout(5)
     csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-    csock.connect(('8.8.8.8', 80))
+    csock.connect(('1.1.1.1', 80))
     (addr, port) = csock.getsockname()
     csock.close()
     return addr
@@ -20,4 +20,4 @@ def Get_local_ip():
 
 if __name__ == "__main__":
   IPADDR = Get_local_ip()
-  print IPADDR
+  print(IPADDR)

+ 3 - 3
include/get_ipaddr_state.py

@@ -8,8 +8,8 @@ try:
   data = eval(content)['data']
   code = eval(content)['code']
   if code == 0:
-    print data['country_id'],data['isp_id']
+    print(data['country_id'])
   else:
-    print data
+    print(data)
 except:
-  print "Usage:%s IP" % sys.argv[0]
+  print("Usage:%s IP" % sys.argv[0])

+ 1 - 1
include/get_public_ipaddr.py

@@ -19,4 +19,4 @@ class Get_public_ip:
 
 if __name__ == "__main__":
   getmyip = Get_public_ip()
-  print getmyip.getip()
+  print(getmyip.getip())

+ 2 - 0
include/nginx.sh

@@ -16,6 +16,8 @@ Install_Nginx() {
   tar xzf pcre-${pcre_ver}.tar.gz
   tar xzf nginx-${nginx_ver}.tar.gz
   tar xzf openssl-${openssl_ver}.tar.gz
+  [ "${Fedora_ver}" == '28' ] && patch -d nginx-${nginx_ver} -p1 < 0001-unix-ngx_user-Apply-fix-for-really-old-bug-in-glibc-.patch
+  patch -d nginx-${nginx_ver} -p0 < nginx-auto-cc-gcc.patch
   pushd nginx-${nginx_ver}
   # Modify Nginx version
   #sed -i 's@#define NGINX_VERSION.*$@#define NGINX_VERSION      "1.2"@' src/core/nginx.h

+ 2 - 0
include/openresty.sh

@@ -16,6 +16,8 @@ Install_OpenResty() {
   tar xzf pcre-${pcre_ver}.tar.gz
   tar xzf openresty-${openresty_ver}.tar.gz
   tar xzf openssl-${openssl_ver}.tar.gz
+  [ "${Fedora_ver}" == '28' ] && patch -d openresty-${openresty_ver}/bundle/nginx-1.13.6 -p1 < 0001-unix-ngx_user-Apply-fix-for-really-old-bug-in-glibc-.patch
+  patch -d openresty-${openresty_ver}/bundle/nginx-1.13.6 -p0 < nginx-auto-cc-gcc.patch
   pushd openresty-${openresty_ver}
 
   # close debug

+ 21 - 12
include/pureftpd.sh

@@ -16,24 +16,33 @@ Install_PureFTPd() {
   tar xzf pure-ftpd-${pureftpd_ver}.tar.gz
   pushd pure-ftpd-${pureftpd_ver}
   [ ! -d "${pureftpd_install_dir}" ] && mkdir -p ${pureftpd_install_dir}
-  ./configure --prefix=${pureftpd_install_dir} CFLAGS=-O2 --with-puredb --with-quotas --with-cookie --with-virtualhosts --with-virtualchroot --with-diraliases --with-sysquotas --with-ratios --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg  --with-throttling --with-uploadscript --with-language=english --with-rfc2640 --with-tls
+  ./configure --prefix=${pureftpd_install_dir} CFLAGS=-O2 --with-puredb --with-quotas --with-cookie --with-virtualhosts --with-virtualchroot --with-diraliases --with-sysquotas --with-ratios --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg --with-throttling --with-uploadscript --with-language=english --with-rfc2640 --with-tls
   make -j ${THREAD} && make install
+  popd
   if [ -e "${pureftpd_install_dir}/sbin/pure-ftpwho" ]; then
+    if [ -e /bin/systemctl ]; then
+      /bin/cp ../init.d/pureftpd.service /lib/systemd/system/
+      sed -i "s@/usr/local/pureftpd@${pureftpd_install_dir}@g" /lib/systemd/system/pureftpd.service
+      systemctl enable pureftpd
+    else
+      /bin/cp ../init.d/Pureftpd-init /etc/init.d/pureftpd
+      sed -i "s@/usr/local/pureftpd@${pureftpd_install_dir}@g" /etc/init.d/pureftpd
+      chmod +x /etc/init.d/pureftpd
+      [ "${OS}" == 'CentOS' ] && { chkconfig --add pureftpd; chkconfig pureftpd on; }
+      [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && { sed -i 's@^. /etc/rc.d/init.d/functions@. /lib/lsb/init-functions@' /etc/init.d/pureftpd; update-rc.d pureftpd defaults; }
+      [ "${Debian_ver}" == '7' ] && sed -i 's@/var/lock/subsys/@/var/lock/@g' /etc/init.d/pureftpd
+    fi
+
     [ ! -e "${pureftpd_install_dir}/etc" ] && mkdir ${pureftpd_install_dir}/etc
-    popd
-    /bin/cp ../init.d/Pureftpd-init /etc/init.d/pureftpd
     /bin/cp ../config/pure-ftpd.conf ${pureftpd_install_dir}/etc
-    sed -i "s@/usr/local/pureftpd@${pureftpd_install_dir}@g" /etc/init.d/pureftpd
-    chmod +x /etc/init.d/pureftpd
-    [ "${OS}" == "CentOS" ] && { chkconfig --add pureftpd; chkconfig pureftpd on; }
-    [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && { sed -i 's@^. /etc/rc.d/init.d/functions@. /lib/lsb/init-functions@' /etc/init.d/pureftpd; update-rc.d pureftpd defaults; }
-    [ "${Debian_ver}" == '7' ] && sed -i 's@/var/lock/subsys/@/var/lock/@g' /etc/init.d/pureftpd
-
     sed -i "s@^PureDB.*@PureDB  ${pureftpd_install_dir}/etc/pureftpd.pdb@" ${pureftpd_install_dir}/etc/pure-ftpd.conf
     sed -i "s@^LimitRecursion.*@LimitRecursion  65535 8@" ${pureftpd_install_dir}/etc/pure-ftpd.conf
-    openssl req -x509 -days 7300 -sha256 -nodes -subj "/C=CN/ST=Shanghai/L=Shanghai/O=OneinStack/CN=${IPADDR}" -newkey rsa:2048 -keyout ${pureftpd_install_dir}/etc/pure-ftpd.pem -out ${pureftpd_install_dir}/etc/pure-ftpd.pem
-    chmod 600 ${pureftpd_install_dir}/etc/pure-ftpd.pem
-    sed -i "s@^# TLS.*@&\nCertFile                   ${pureftpd_install_dir}/etc/pure-ftpd.pem@" ${pureftpd_install_dir}/etc/pure-ftpd.conf
+    [ -z "${IPADDR}" ] && IPADDR=127.0.0.1
+    [ ! -d /etc/ssl/private ] && mkdir -p /etc/ssl/private
+    openssl dhparam -out /etc/ssl/private/pure-ftpd-dhparams.pem 2048
+    openssl req -x509 -days 7300 -sha256 -nodes -subj "/C=CN/ST=Shanghai/L=Shanghai/O=OneinStack/CN=${IPADDR}" -newkey rsa:2048 -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem
+    chmod 600 /etc/ssl/private/pure-ftpd*.pem
+    sed -i "s@^# TLS.*@&\nCertFile                   /etc/ssl/private/pure-ftpd.pem@" ${pureftpd_install_dir}/etc/pure-ftpd.conf
     sed -i "s@^# TLS.*@&\nTLSCipherSuite             HIGH:MEDIUM:+TLSv1:\!SSLv2:\!SSLv3@" ${pureftpd_install_dir}/etc/pure-ftpd.conf
     sed -i "s@^# TLS.*@TLS                        1@" ${pureftpd_install_dir}/etc/pure-ftpd.conf
     ulimit -s unlimited

+ 1 - 1
include/python.sh

@@ -60,7 +60,7 @@ EOF
   if [ ! -e "/root/.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=$(../include/get_ipaddr_state.py $PUBLIC_IPADDR)
     if [ "$IPADDR_COUNTRY"x == "CN"x ]; then
       [ ! -d "/root/.pip" ] && mkdir /root/.pip
       echo -e "[global]\nindex-url = https://pypi.tuna.tsinghua.edu.cn/simple" > /root/.pip/pip.conf

+ 2 - 0
include/tengine.sh

@@ -16,6 +16,8 @@ Install_Tengine() {
   tar xzf pcre-${pcre_ver}.tar.gz
   tar xzf tengine-${tengine_ver}.tar.gz
   tar xzf openssl-${openssl_ver}.tar.gz
+  [ "${Fedora_ver}" == '28' ] && patch -d tengine-${tengine_ver} -p1 < 0001-unix-ngx_user-Apply-fix-for-really-old-bug-in-glibc-.patch
+  patch -d tengine-${tengine_ver} -p0 < nginx-auto-cc-gcc.patch
   pushd tengine-${tengine_ver}
   # Modify Tengine version
   #sed -i 's@TENGINE "/" TENGINE_VERSION@"Tengine/unknown"@' src/core/nginx.h

+ 6 - 0
include/upgrade_web.sh

@@ -42,6 +42,8 @@ Upgrade_Nginx() {
     echo "Press Ctrl+c to cancel or Press any key to continue..."
     char=`get_char`
     tar xzf nginx-${NEW_nginx_ver}.tar.gz
+    [ "${Fedora_ver}" == '28' ] && patch -d nginx-${nginx_ver} -p1 < 0001-unix-ngx_user-Apply-fix-for-really-old-bug-in-glibc-.patch
+    patch -d nginx-${nginx_ver} -p0 < nginx-auto-cc-gcc.patch
     pushd nginx-${NEW_nginx_ver}
     make clean
     sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc # close debug
@@ -100,6 +102,8 @@ Upgrade_Tengine() {
     echo "Press Ctrl+c to cancel or Press any key to continue..."
     char=`get_char`
     tar xzf tengine-${NEW_tengine_ver}.tar.gz
+    [ "${Fedora_ver}" == '28' ] && patch -d tengine-${tengine_ver} -p1 < 0001-unix-ngx_user-Apply-fix-for-really-old-bug-in-glibc-.patch
+    patch -d tengine-${tengine_ver} -p0 < nginx-auto-cc-gcc.patch
     pushd tengine-${NEW_tengine_ver}
     make clean
     sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc # close debug
@@ -163,6 +167,8 @@ Upgrade_OpenResty() {
     echo "Press Ctrl+c to cancel or Press any key to continue..."
     char=`get_char`
     tar xzf openresty-${NEW_openresy_ver}.tar.gz
+    [ "${Fedora_ver}" == '28' ] && patch -d openresty-${openresty_ver}/bundle/nginx-1.13.6 -p1 < 0001-unix-ngx_user-Apply-fix-for-really-old-bug-in-glibc-.patch
+    patch -d openresty-${openresty_ver}/bundle/nginx-1.13.6 -p0 < nginx-auto-cc-gcc.patch
     pushd openresty-${NEW_openresy_ver}
     make clean
     openresty_ver_tmp=${NEW_openresy_ver%.*}

+ 11 - 0
init.d/pureftpd.service

@@ -0,0 +1,11 @@
+[Unit]
+Description=Pure-FTPd FTP server
+After=network.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/pure-ftpd.pid
+ExecStart=/usr/local/pureftpd/sbin/pure-ftpd /usr/local/pureftpd/etc/pure-ftpd.conf
+
+[Install]
+WantedBy=multi-user.target

+ 3 - 4
install.sh

@@ -654,10 +654,9 @@ if [ ${ARG_NUM} == 0 ]; then
 fi
 
 # get the IP information
-IPADDR=`./include/get_ipaddr.py`
-PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
-IPADDR_COUNTRY_ISP=`./include/get_ipaddr_state.py $PUBLIC_IPADDR`
-IPADDR_COUNTRY=`echo $IPADDR_COUNTRY_ISP | awk '{print $1}'`
+IPADDR=$(./include/get_ipaddr.py)
+PUBLIC_IPADDR=$(./include/get_public_ipaddr.py)
+IPADDR_COUNTRY=$(./include/get_ipaddr_state.py $PUBLIC_IPADDR)
 
 # Check download source packages
 . ./include/check_download.sh

+ 30 - 0
src/0001-unix-ngx_user-Apply-fix-for-really-old-bug-in-glibc-.patch

@@ -0,0 +1,30 @@
+From f446736d4f4c5f7ae81bb8bf84fda7ce3c9d49a0 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <besser82@fedoraproject.org>
+Date: Wed, 24 Jan 2018 12:37:48 +0100
+Subject: [PATCH] unix/ngx_user: Apply fix for really old bug in glibc libcrypt
+ if needed
+
+---
+ src/os/unix/ngx_user.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/src/os/unix/ngx_user.c b/src/os/unix/ngx_user.c
+index 7ebe2b57..d0fe9238 100644
+--- a/src/os/unix/ngx_user.c
++++ b/src/os/unix/ngx_user.c
+@@ -21,8 +21,10 @@ ngx_libc_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted)
+     struct crypt_data   cd;
+ 
+     cd.initialized = 0;
+-#ifdef __GLIBC__
+-    /* work around the glibc bug */
++#if (defined(__GLIBC__) && __GLIBC__ == 2) && \
++    (defined(__GLIBC_MINOR__) && __GLIBC_MINOR__ >= 2 && __GLIBC_MINOR__ < 4)
++    /* work around glibc-2.2.5 bug,
++     * has been fixed at some time in glibc-2.3.X */
+     cd.current_salt[0] = ~salt[0];
+ #endif
+ 
+-- 
+2.16.1
+

+ 13 - 0
src/nginx-auto-cc-gcc.patch

@@ -0,0 +1,13 @@
+--- auto/cc/gcc.orig	2007-03-22 08:34:53.000000000 -0600
++++ auto/cc/gcc	2007-03-22 08:58:47.000000000 -0600
+@@ -172,7 +172,9 @@
+ 
+ 
+ # stop on warning
+-CFLAGS="$CFLAGS -Werror"
++# This combined with Fedora's FORTIFY_SOURCE=2 option causes it nginx
++# to not compile.
++#CFLAGS="$CFLAGS -Werror"
+ 
+ # debug
+ CFLAGS="$CFLAGS -g"

+ 2 - 2
upgrade.sh

@@ -38,8 +38,8 @@ pushd ${oneinstack_dir} > /dev/null
 . ./include/upgrade_oneinstack.sh
 
 # get the IP information
-PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
-IPADDR_COUNTRY=`./include/get_ipaddr_state.py $PUBLIC_IPADDR | awk '{print $1}'`
+PUBLIC_IPADDR=$(./include/get_public_ipaddr.py)
+IPADDR_COUNTRY=$(./include/get_ipaddr_state.py $PUBLIC_IPADDR)
 
 Usage(){
   printf "

+ 3 - 3
versions.txt

@@ -27,7 +27,7 @@ mariadb103_ver=10.3.8
 mariadb102_ver=10.2.16
 mariadb101_ver=10.1.34
 mariadb100_ver=10.0.35
-mariadb55_ver=5.5.60
+mariadb55_ver=5.5.61
 
 percona57_ver=5.7.22-22
 percona56_ver=5.6.40-84.0
@@ -79,7 +79,7 @@ pureftpd_ver=1.0.47
 
 # Redis
 redis_ver=4.0.10
-redis_pecl_ver=4.1.0
+redis_pecl_ver=4.1.1
 
 # Memcached
 memcached_ver=1.5.9
@@ -100,7 +100,7 @@ phpmyadmin_oldver=4.4.15.10
 jemalloc_ver=5.1.0
 
 # boost
-boost_ver=1.66.0
+boost_ver=1.67.0
 boost_oldver=1.59.0
 
 # Others

+ 2 - 1
vhost.sh

@@ -193,7 +193,8 @@ If you enter '.', the field will be left blank.
           echo "${CWARNING}Syntax error! PS: export Ali_Key=LTq ; export Ali_Secret=0q5E${CEND}"
         fi
       done
-      ~/.acme.sh/acme.sh --issue --dns dns_${DNS_PRO} -d ${domain} -d ${moredomain}
+      [ "${moredomainame_flag}" == 'y' ] && moredomainame_D="$(for D in ${moredomainame}; do echo -d ${D}; done)"
+      ~/.acme.sh/acme.sh --issue --dns dns_${DNS_PRO} -d ${domain} ${moredomainame_D}
     else
       if [ "${nginx_ssl_flag}" == 'y' ]; then
         [ ! -d ${web_install_dir}/conf/vhost ] && mkdir ${web_install_dir}/conf/vhost