1+ #! /bin/bash
2+ 
3+ 
4+ 
5+ #  Define NGINX version
6+ PACKAGE_NAME=$1 
7+ NGINX_VERSION=$2 
8+ EMAIL_ADDRESS=$3 
9+ 
10+ #  Capture errors
11+ function  ppa_error() 
12+ {
13+ echo  " [ ` date` $( tput setaf 1) $@ $( tput sgr0) " 
14+ exit  $2 
15+ }
16+ 
17+ #  Echo function
18+ function  ppa_lib_echo() 
19+ {
20+ echo  $( tput setaf 4) $@ $( tput sgr0) 
21+ }
22+ 
23+ #  Update/Install Packages
24+ ppa_lib_echo " Execute: apt-get update, please wait" 
25+ sudo apt-get update ||  ppa_error " Unable to update packages, exit status = " $? 
26+ ppa_lib_echo " Installing required packages, please wait" 
27+ sudo apt-get -y install git dh-make devscripts debhelper dput gnupg-agent dh-systemd ||  ppa_error " Unable to install packages, exit status = " $? 
28+ 
29+ #  Lets Clone Launchpad repository
30+ ppa_lib_echo " Copy Launchpad Debian files, please wait" 
31+ rm -rf /tmp/launchpad &&  git clone -b nginx-official https://github.com/MiteshShah/launchpad.git /tmp/launchpad \
32+ ||  ppa_error " Unable to clone launchpad repo, exit status = " $? 
33+ 
34+ if  [ " $PACKAGE_NAME " =  " init-system-helpers" ;  then 
35+ #  Configure init-system-helpers for Ubuntu 12.04
36+ mkdir -p ~ /PPA/$PACKAGE_NAME  &&  cd  ~ /PPA/$PACKAGE_NAME  \
37+ ||  ppa_error " Unable to create ~/PPA/$PACKAGE_NAME , exit status = " $? 
38+ 
39+ #  Clone init-system-helpers
40+ ppa_lib_echo " Clone init-system-helpers, please wait" 
41+ git clone git://anonscm.debian.org/collab-maint/init-system-helpers.git init-system-helpers-1.7
42+ cd  init-system-helpers-1.7 &&  git checkout debian/1.7 \
43+ ||  ppa_error " Unable to checkout debian/1.7, exit status = " $? 
44+ 
45+ #  Lets start building
46+ # ppa_lib_echo "Execute: dh_make --single --copyright gpl --email $EMAIL_ADDRESS --createorig, please wait"
47+ # dh_make --single --copyright gpl --email $EMAIL_ADDRESS --createorig \
48+ # || ppa_error "Unable to run dh_make command, exit status = " $?
49+ 
50+ #  Let's copy files
51+ cp -av /tmp/launchpad/init-system-helpers/debian/*  ~ /PPA/init-system-helpers/init-system-helpers-1.7/debian/ \
52+ ||  ppa_error " Unable to copy launchpad debian files, exit status = " $? 
53+ elif  [ " $PACKAGE_NAME " =  " nginx" ;  then 
54+ 
55+ #  Configure NGINX PPA
56+ mkdir -p ~ /PPA/$PACKAGE_NAME  &&  cd  ~ /PPA/$PACKAGE_NAME  \
57+ ||  ppa_error " Unable to create ~/PPA/$PACKAGE_NAME , exit status = " $? 
58+ 
59+ #  Download NGINX
60+ ppa_lib_echo " Download nginx, please wait" 
61+ wget -c http://nginx.org/download/nginx-${NGINX_VERSION} .tar.gz \
62+ ||  ppa_error " Unable to download nginx-${NGINX_VERSION} .tar.gz, exit status = " $? 
63+ tar -zxvf nginx-${NGINX_VERSION} .tar.gz \
64+ ||  ppa_error " Unable to extract nginx, exit status = " $? 
65+ cd  nginx-${NGINX_VERSION}  \
66+ ||  ppa_error " Unable to change directory, exit status = " $? 
67+ 
68+ #  Lets start building
69+ ppa_lib_echo " Execute: dh_make --single --copyright gpl --email $EMAIL_ADDRESS  --createorig, please wait" 
70+ dh_make --single --copyright gpl --email $EMAIL_ADDRESS  --createorig \
71+ ||  ppa_error " Unable to run dh_make command, exit status = " $? 
72+ rm debian/* .ex debian/* .EX \
73+ ||  ppa_error " Unable to remove unwanted files, exit status = " $? 
74+ 
75+ #  Let's copy files
76+ cp -av /tmp/launchpad/nginx/debian/*  ~ /PPA/nginx/nginx-${NGINX_VERSION} /debian/ \
77+ ||  ppa_error " Unable to copy launchpad debian files, exit status = " $? 
78+ 
79+ 
80+ 
81+ #  NGINX modules
82+ ppa_lib_echo " Downloading NGINX modules, please wait" 
83+ mkdir ~ /PPA/nginx/modules &&  cd  ~ /PPA/nginx/modules \
84+ ||  ppa_error " Unable to create ~/PPA/nginx/modules, exit status = " $? 
85+ 
86+ ppa_lib_echo " 1/14 headers-more-nginx-module" 
87+ git clone https://github.com/agentzh/headers-more-nginx-module.git \
88+ ||  ppa_error " Unable to clone headers-more-nginx-module repo, exit status = " $? 
89+ 
90+ ppa_lib_echo " 2/14 naxsi " 
91+ git clone https://github.com/nbs-system/naxsi \
92+ ||  ppa_error " Unable to clone naxsi repo, exit status = " $? 
93+ cp -av ~ /PPA/nginx/modules/naxsi/naxsi_config/naxsi_core.rules ~ /PPA/nginx/nginx-${NGINX_VERSION} /debian/conf/ \
94+ ||  ppa_error " Unable to copy naxsi files, exit status = " $? 
95+ 
96+ ppa_lib_echo " 3/14 nginx-auth-pam" 
97+ wget http://web.iti.upv.es/~sto/nginx/ngx_http_auth_pam_module-1.3.tar.gz \
98+ ||  ppa_error " Unable to download ngx_http_auth_pam_module-1.3.tar.gz, exit status = " $? 
99+ tar -zxvf ngx_http_auth_pam_module-1.3.tar.gz \
100+ ||  ppa_error " Unable to extract ngx_http_auth_pam_module-1.3, exit status = " $? 
101+ mv ngx_http_auth_pam_module-1.3 nginx-auth-pam \
102+ ||  ppa_error " Unable to rename ngx_http_auth_pam_module-1.3, exit status = " $? 
103+ rm ngx_http_auth_pam_module-1.3.tar.gz \
104+ ||  ppa_error " Unable to remove ngx_http_auth_pam_module-1.3.tar.gz, exit status = " $? 
105+ 
106+ ppa_lib_echo " 4/14 nginx-cache-purge" 
107+ git clone https://github.com/FRiCKLE/ngx_cache_purge.git nginx-cache-purge \
108+ ||  ppa_error " Unable to clone nginx-cache-purge repo, exit status = " $? 
109+ 
110+ ppa_lib_echo " 5/14 nginx-dav-ext-module" 
111+ git clone https://github.com/arut/nginx-dav-ext-module.git \
112+ ||  ppa_error " Unable to clone nginx-dav-ext-module repo, exit status = " $? 
113+ 
114+ ppa_lib_echo " 6/14 nginx-development-kit" 
115+ git clone https://github.com/simpl/ngx_devel_kit.git nginx-development-kit \
116+ ||  ppa_error " Unable to clone nginx-development-kit repo, exit status = " $? 
117+ 
118+ ppa_lib_echo " 7/14 nginx-echo" 
119+ git clone https://github.com/agentzh/echo-nginx-module.git nginx-echo \
120+ ||  ppa_error " Unable to clone nginx-echo repo, exit status = " $? 
121+ 
122+ ppa_lib_echo " 8/14 nginx-http-push" 
123+ git clone https://github.com/slact/nginx_http_push_module.git nginx-http-push \
124+ ||  ppa_error " Unable to clone nginx-http-push repo, exit status = " $? 
125+ 
126+ ppa_lib_echo " 9/14 nginx-lua" 
127+ git clone https://github.com/chaoslawful/lua-nginx-module.git nginx-lua \
128+ ||  ppa_error " Unable to clone nginx-lua repo, exit status = " $? 
129+ 
130+ ppa_lib_echo " 10/14 nginx-upload-progress-module" 
131+ git clone https://github.com/masterzen/nginx-upload-progress-module.git nginx-upload-progress \
132+ ||  ppa_error " Unable to clone nginx-upload-progress repo, exit status = " $? 
133+ 
134+ ppa_lib_echo " 11/14 nginx-upstream-fair" 
135+ git clone https://github.com/gnosek/nginx-upstream-fair.git \
136+ ||  ppa_error " Unable to clone nginx-upstream-fair repo, exit status = " $? 
137+ 
138+ ppa_lib_echo " 12/14 ngx-fancyindex" 
139+ git clone https://github.com/aperezdc/ngx-fancyindex.git ngx-fancyindex \
140+ ||  ppa_error " Unable to clone ngx-fancyindex repo, exit status = " $? 
141+ 
142+ 
143+ ppa_lib_echo " 12/14 ngx_http_substitutions_filter_module" 
144+ git clone git://github.com/yaoweibin/ngx_http_substitutions_filter_module.git \
145+ ||  ppa_error " Unable to clone ngx_http_substitutions_filter_module repo, exit status = " $? 
146+ 
147+ ppa_lib_echo " 13/14 ngx_pagespeed" 
148+ NPS_VERSION=1.9.32.2
149+ wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION} -beta.tar.gz
150+ tar -zxvf release-${NPS_VERSION} -beta.tar.gz
151+ mv ngx_pagespeed-release-${NPS_VERSION} -beta ngx_pagespeed
152+ rm release-${NPS_VERSION} -beta.tar.gz
153+ 
154+ cd  ngx_pagespeed
155+ wget -O psol.tar.gz https://dl.google.com/dl/page-speed/psol/${NPS_VERSION} .tar.gz
156+ 
157+ cp -av ~ /PPA/nginx/modules ~ /PPA/nginx/nginx-${NGINX_VERSION} /debian/ \
158+ ||  ppa_error " Unable to copy launchpad modules files, exit status = " $? 
159+ fi 
0 commit comments