Last active
August 29, 2015 14:18
-
-
Save Saneyan/1c3dc9ba188d02ebebf4 to your computer and use it in GitHub Desktop.
Nginx build scirpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| # LibreSSL Setup Script authored by TADOKORO Saneyuki | |
| # Date: 8th April, 2015 | |
| # | |
| tdir=/tmp/$(whoami)-libressl-install | |
| prefix=/usr/include/libressl | |
| function install() { | |
| if ! [[ "$1" =~ ^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}$ ]]; then | |
| echo "Specify LibreSSL version like 'x.x.x'. Aborting." | |
| exit 1 | |
| fi | |
| local fn=libressl-$1 | |
| mkdir -vp --mode=700 $tdir | |
| echo "==> Getting sources..." | |
| curl http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-$1.tar.gz > $tdir/$fn.tar.gz | |
| cd $tdir | |
| if ! [[ "$(file -ib $fn.tar.gz)" =~ ^application/x-gzip ]]; then | |
| echo "No compressed file found. Aborting." | |
| exit 1 | |
| fi | |
| echo "--> Unpacking sources..." | |
| tar zxvf $fn.tar.gz | |
| echo "--> Entering $1" | |
| cd $fn | |
| echo "==> Configuring Nginx..." | |
| ./configure --prefix=$prefix LDFLAGS=-lrt | |
| echo "==> Compiling LibreSSL..." | |
| make | |
| echo "==> Installing LibreSSL..." | |
| #sudo make install | |
| cd; mv $fn $prefix | |
| echo "==> Cleaning..." | |
| rm -rf $tdir | |
| } | |
| function deinstall() { | |
| echo "==> Removing files..." | |
| sudo rm -rfv $prefix | |
| } | |
| case $1 in | |
| install) install ${@:2} ;; | |
| deinstall) deinstall ${@:2} ;; | |
| *) echo "install|deinstall"; exit 1 ;; | |
| esac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| # Nginx Setup Script authored by TADOKORO Saneyuki | |
| # Date: 8th April, 2015 | |
| # | |
| tdir=/tmp/$(whoami)-nginx-install | |
| prefix=/etc/nginx | |
| sbin_path=/usr/sbin/nginx | |
| conf_path=/etc/nginx/nginx.conf | |
| error_log_path=/var/log/nginx/error.log | |
| http_client_body_temp_path=/var/lib/nginx/body | |
| http_fastcgi_temp_path=/var/lib/nginx/fastcgi | |
| http_log_path=/var/log/nginx/access.log | |
| http_proxy_temp_path=/var/lib/nginx/proxy | |
| http_scgi_temp_path=/var/lib/nginx/scgi | |
| http_uwsgi_temp_path=/var/lib/nginx/uwsgi | |
| lock_path=/var/lock/nginx.lock | |
| pid_path=/var/run/nginx.pid | |
| ssllib_path=/usr/include/libressl | |
| function install_dep() { | |
| # for apt | |
| sudo aptitude install libpcre3 libpcre3-dev unzip zlib1g zlib1g-dev openssl libssl-dev libxslt-dev libgd2-xpm-dev libgeoip-dev | |
| # for another distribution | |
| # ... | |
| } | |
| function install() { | |
| if [ -e $sbin_path ]; then | |
| echo "Nginx has already been installed. Aborting." | |
| exit 1 | |
| fi | |
| if ! [[ "$1" =~ ^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}$ ]]; then | |
| echo "Specify nginx version like 'x.x.x'. Aborting." | |
| exit 1 | |
| fi | |
| echo "==> Installing required packages..." | |
| install_dep | |
| local fn=nginx-$1 | |
| mkdir -vp --mode=700 $tdir | |
| echo "==> Getting sources..." | |
| curl http://nginx.org/download/$fn.tar.gz > $tdir/$fn.tar.gz | |
| cd $tdir | |
| if ! [[ "$(file -ib $fn.tar.gz)" =~ ^application/x-gzip ]]; then | |
| echo "No compressed file found. Aborting." | |
| exit 1 | |
| fi | |
| echo "--> Unpacking sources..." | |
| tar zxvf $fn.tar.gz | |
| echo "--> Entering $1" | |
| cd $fn | |
| echo "==> Configuring Nginx..." | |
| ./configure \ | |
| --prefix=$prefix \ | |
| --sbin-path=$sbin_path \ | |
| --conf-path=$conf_path \ | |
| --error-log-path=$error_log_path \ | |
| --http-client-body-temp-path=$http_client_body_temp_path \ | |
| --http-fastcgi-temp-path=$http_fastcgi_temp_path \ | |
| --http-log-path=$http_log_path \ | |
| --http-proxy-temp-path=$http_proxy_temp_path \ | |
| --http-scgi-temp-path=$http_scgi_temp_path \ | |
| --http-uwsgi-temp-path=$http_uwsgi_temp_path \ | |
| --lock-path=$lock_path \ | |
| --pid-path=$pid_path \ | |
| --with-pcre-jit \ | |
| --with-debug \ | |
| --with-http_addition_module \ | |
| --with-http_dav_module \ | |
| --with-http_geoip_module \ | |
| --with-http_gzip_static_module \ | |
| --with-http_image_filter_module \ | |
| --with-http_realip_module \ | |
| --with-http_stub_status_module \ | |
| --with-http_ssl_module \ | |
| --with-http_sub_module \ | |
| --with-http_xslt_module \ | |
| --with-ipv6 \ | |
| --with-openssl=$ssllib_path \ | |
| --with-sha1=$ssllib_path \ | |
| --with-md5=$ssllib_path \ | |
| --with-mail \ | |
| --with-mail_ssl_module \ | |
| --with-ld-opt="-lrt" | |
| echo "==> Compiling Nginx..." | |
| make | |
| echo "==> Installing Nginx..." | |
| sudo make install | |
| echo "==> Cleaning..." | |
| cd; rm -rf $tdir | |
| } | |
| function deinstall() { | |
| if ! [ -e $sbin_path ]; then | |
| echo "Nginx has not been installed. Aborting." | |
| exit 1 | |
| fi | |
| local ad= ans= | |
| if [[ "$1" == "all" ]]; then | |
| while true; do | |
| echo -n "Would you like to remove all files including config files? (yes or no): " | |
| read ans | |
| case $ans in | |
| [yY]es) ad=$prefix; break ;; | |
| [nN]o) break ;; | |
| *) echo -n "Type yes or no: " ;; | |
| esac | |
| done | |
| fi | |
| echo "==> Removing files..." | |
| sudo rm -rfv $ad \ | |
| $sbin_path \ | |
| $conf_path \ | |
| $error_log_path \ | |
| $http_client_body_temp_path \ | |
| $http_fastcgi_temp_path \ | |
| $http_log_path \ | |
| $http_proxy_temp_path \ | |
| $http_scgi_temp_path \ | |
| $http_uwsgi_temp_path \ | |
| $lock_path \ | |
| $pid_path | |
| } | |
| function reinstall() { | |
| if ! [ -e $sbin_path ]; then | |
| echo "Nginx has not been installed. Aborting." | |
| exit 1 | |
| fi | |
| local ver=$($sbin_path -v 2>&1 | sed "s,nginx version: nginx/,,") | |
| deinstall | |
| install $ver | |
| } | |
| case $1 in | |
| install) install ${@:2} ;; | |
| deinstall) deinstall ${@:2} ;; | |
| reinstall) reinstall ${@:2} ;; | |
| *) echo "install|deinstall|reinstall"; exit 1 ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment