#!/bin/bash +x ARGV=($@) WORK_PATH=$(pwd) # Пакеты будут скачены с "$url" url="https://update.cryptopro.ru/support/nginx-gost" revision_openssl="211453" release_openssl="5.0.11803-6" pcre_ver="pcre-8.44" zlib_ver="zlib-1.2.11" # Версия nginx для загрузки с github nginx_branch="stable-1.16" # Определение команд под систему cat /etc/*release* | grep -Ei "(centos|red hat)" > /dev/null if [ "$?" -eq 0 ] then apt="yum -y" pkgmsys="rpm" pkglist="rpm -qa" install="rpm -i" openssl_packages=(cprocsp-cpopenssl-110-base-${release_openssl}.noarch.rpm \ cprocsp-cpopenssl-110-64-${release_openssl}.x86_64.rpm \ cprocsp-cpopenssl-110-devel-${release_openssl}.noarch.rpm \ cprocsp-cpopenssl-110-gost-64-${release_openssl}.x86_64.rpm) modules_path=/usr/lib64/nginx/modules cc_ld_opt=" --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'" else cat /etc/*release* | grep -Ei "(ubuntu|debian)" > /dev/null if [ "$?" -eq 0 ] then apt="apt-get" pkgmsys="deb" pkglist="dpkg-query --list" install="dpkg -i" openssl_packages=(cprocsp-cpopenssl-110-base_${release_openssl}_all.deb \ cprocsp-cpopenssl-110-64_${release_openssl}_amd64.deb \ cprocsp-cpopenssl-110-devel_${release_openssl}_all.deb \ cprocsp-cpopenssl-110-gost-64_${release_openssl}_amd64.deb) modules_path=/usr/lib/nginx/modules cc_ld_opt=" --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'" else printf "Not supported system (supported: Ubuntu, Debian, CentOS, Red Hat).\n" exit 0 fi fi # ---------------------------------------------- prefix=/etc/nginx sbin_path=/usr/sbin/nginx conf_path=/etc/nginx/nginx.conf err_log_path=/var/log/nginx/error.log http_log_path=/var/log/nginx/access.log pid_path=/var/run/nginx.pid lock_path=/var/run/nginx.lock http_client_body_temp_path=/var/cache/nginx/client_temp http_proxy_temp_path=/var/cache/nginx/proxy_temp http_fastcgi_temp_path=/var/cache/nginx/fastcgi_temp http_uwsgi_temp_path=/var/cache/nginx/uwsgi_temp http_scgi_temp_path=/var/cache/nginx/scgi_temp user=root group=nginx # Настройка установочной конфигурации nginx nginx_paths=" --prefix=${prefix} --sbin-path=${sbin_path} --modules-path=${modules_path} --conf-path=${conf_path} --error-log-path=${err_log_path} --http-log-path=${http_log_path} --http-client-body-temp-path=${http_client_body_temp_path} --http-proxy-temp-path=${http_proxy_temp_path} --http-fastcgi-temp-path=${http_fastcgi_temp_path} --http-uwsgi-temp-path=${http_uwsgi_temp_path} --http-scgi-temp-path=${http_scgi_temp_path} --pid-path=${pid_path} --lock-path=${lock_path}" nginx_parametrs=" --user=${user} --group=${group} --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module" # Возможны и другие модули для которых требуется самостоятельная установка пакетов, например: # --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic # --with-http_perl_module=dynamic # ---------------------------------------------- # ---------------------------------------------- # -----------Проверка аргументов,--------------- # ------определение необходимых пакетов--------- # ---------------------------------------------- command_list=false git_need="" gcc_need="" zlib_need="" pcre_need="" openssl_need="" nginx_need="" csp_need="" csp="" # Проверка аргументов и CSP for arg_cur in "${ARGV[@]}" do term="$(echo ${arg_cur}|awk -F= '/^\-\-.+=.+/{print $1}')" define="$(echo ${arg_cur}|awk -F= '/^\-\-.+=.+/{print $2}')" if test "${term}" != "" then case ${term} in # Проверка CSP "--csp") csp=${define} ;; "--install") # git if test "${define}" == "git" then git_need=true # gcc elif test "${define}" == "gcc" then gcc_need=true # zlib elif test "${define}" == "zlib" then zlib_need=true # pcre elif test "${define}" == "pcre" then pcre_need=true # csp elif test "${define}" == "csp" then csp_need=true # openssl elif test "${define}" == "openssl" then openssl_need=true # nginx elif test "${define}" == "nginx" then nginx_need=true else echo "Bad value for \"${term}\": ${define}" exit 1 fi ;; "--noinstall") # git if test "${define}" == "git" then git_need=false # gcc elif test "${define}" == "gcc" then gcc_need=false # zlib elif test "${define}" == "zlib" then zlib_need=false # pcre elif test "${define}" == "pcre" then pcre_need=false else echo "Bad value for \"${term}\": ${define}" exit 1 fi ;; *) echo "Bad arg: ${term}" exit 1 ;; esac # Проверка command list elif echo "${arg_cur}" | grep "\-\-command_list" > /dev/null then command_list=true # Вывод справки elif echo "${arg_cur}" | grep "\-\-help" > /dev/null then echo "Usage: ./install-nginx.sh