Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow omitting configuration, resolves #96 #99

Merged
merged 1 commit into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Automated Nginx compilation from sources with additional modules support
* Automated nginx updates cronjob
* Compilation with GCC-7/9
* Security hardening and performance optimization enabled with proper GCC flags
* An option to omitt nginx configuration, allowing usage of third party devops tools

---

Expand Down Expand Up @@ -171,6 +172,7 @@ Nginx build options :
* `--stable` : compile Nginx stable release
* `--full` : Naxsi + PageSpeed + RTMP
* `--dynamic` : Compile Nginx modules as dynamic modules
* `--noconf` : Compile Nginx without any configuring. Useful when you use devops tools like ansible.

Optional third-party modules :

Expand Down Expand Up @@ -202,6 +204,7 @@ Extras :
* [x] Add openssl release choice
* [x] Add more compilation presets
* [x] Add support for LibreSSL
* [x] Add noconf support
* [ ] Add support for config.inc build configuration
* [ ] Add HTTP/3 QUIC support

Expand Down
69 changes: 43 additions & 26 deletions nginx-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ _help() {
echo " --stable ..... Nginx stable release"
echo " --full ..... Nginx mainline release with Pagespeed, Nasxi and RTMP module"
echo " --dynamic ..... Compile Nginx modules as dynamic"
echo " --noconf ..... Compile Nginx without any configuring. Useful when you use devops tools like ansible."
echo " Modules:"
echo " --pagespeed ..... Pagespeed module stable release"
echo " --pagespeed-beta ..... Pagespeed module beta release"
Expand Down Expand Up @@ -75,6 +76,9 @@ else
NAXSI="y"
RTMP="y"
;;
--noconf)
NOCONF="y"
;;
--naxsi)
NAXSI="y"
;;
Expand Down Expand Up @@ -854,7 +858,9 @@ _download_naxsi() {

git clone --depth=50 https://github.com/nbs-system/naxsi.git /usr/local/src/naxsi -q

cp -f /usr/local/src/naxsi/naxsi_config/naxsi_core.rules /etc/nginx/naxsi_core.rules
if [ "$NOCONF" != "y" ]; then
cp -f /usr/local/src/naxsi/naxsi_config/naxsi_core.rules /etc/nginx/naxsi_core.rules
fi

} >>/tmp/nginx-ee.log 2>&1

Expand Down Expand Up @@ -963,7 +969,7 @@ _configure_nginx() {
DEB_LFLAGS="$(dpkg-buildflags --get LDFLAGS)"

if {
echo -ne ' Configuring nginx [..]\r'
echo -ne ' Configuring nginx build [..]\r'

# main configuration
NGINX_BUILD_OPTIONS="--prefix=/usr/share \
Expand Down Expand Up @@ -1192,14 +1198,16 @@ _final_tasks() {
} >>/tmp/nginx-ee.log 2>&1
fi

{
# enable nginx service
systemctl unmask nginx.service
systemctl enable nginx.service
systemctl start nginx.service
# remove default configuration
rm -f /etc/nginx/{*.default,*.dpkg-dist}
} >/dev/null 2>&1
if [ "$NOCONF" != "y" ]; then
{
# enable nginx service
systemctl unmask nginx.service
systemctl enable nginx.service
systemctl start nginx.service
# remove default configuration
rm -f /etc/nginx/{*.default,*.dpkg-dist}
} >/dev/null 2>&1
fi

}; then
echo -ne " Performing final steps [${CGREEN}OK${CEND}]\\r"
Expand All @@ -1212,21 +1220,26 @@ _final_tasks() {

echo -ne ' Checking nginx configuration [..]\r'

# check if nginx -t do not return errors
VERIFY_NGINX_CONFIG=$(nginx -t 2>&1 | grep failed)
if [ -z "$VERIFY_NGINX_CONFIG" ]; then
{
systemctl stop nginx
systemctl start nginx
} >>/tmp/nginx-ee.log 2>&1
echo -ne " Checking nginx configuration [${CGREEN}OK${CEND}]\\r"
echo ""
echo -e " ${CGREEN}Nginx-ee was compiled successfully !${CEND}"
echo -e '\n Installation log : /tmp/nginx-ee.log\n'
if [ "$NOCONF" != "y" ]; then
# check if nginx -t do not return errors
VERIFY_NGINX_CONFIG=$(nginx -t 2>&1 | grep failed)
if [ -z "$VERIFY_NGINX_CONFIG" ]; then
{
systemctl stop nginx
systemctl start nginx
} >>/tmp/nginx-ee.log 2>&1
echo -ne " Checking nginx configuration [${CGREEN}OK${CEND}]\\r"
echo ""
echo -e " ${CGREEN}Nginx-ee was compiled successfully !${CEND}"
echo -e '\n Installation log : /tmp/nginx-ee.log\n'
else
echo -e " Checking nginx configuration [${CRED}FAIL${CEND}]"
echo -e " Nginx-ee was compiled successfully but there is an error in your nginx configuration"
echo -e '\nPlease look at /tmp/nginx-ee.log or use the command nginx -t to find the issue\n'
fi
else
echo -e " Checking nginx configuration [${CRED}FAIL${CEND}]"
echo -e " Nginx-ee was compiled successfully but there is an error in your nginx configuration"
echo -e '\nPlease look at /tmp/nginx-ee.log or use the command nginx -t to find the issue\n'
echo -e " ${CGREEN}Nginx-ee was compiled successfully !${CEND}"
echo -e '\nAs you requested not to configure it, you must do it manually or using your favourite devops tools.\n'
fi

}
Expand All @@ -1238,7 +1251,9 @@ _final_tasks() {
_dependencies_repo
_install_dependencies
if [ "$NGINX_FROM_SCRATCH" = "1" ]; then
_nginx_from_scratch_setup
if [ "$NOCONF" != "y" ]; then
_nginx_from_scratch_setup
fi
fi
if [ "$DISTRO_ID" = "Ubuntu" ]; then
_gcc_ubuntu_setup
Expand Down Expand Up @@ -1276,7 +1291,9 @@ if [ "$CRON_SETUP" = "y" ]; then
_cron_setup
fi
if [ "$DYNAMIC_MODULES" = "y" ]; then
_dynamic_setup
if [ "$NOCONF" != "y" ]; then
_dynamic_setup
fi
fi
_final_tasks
echo "Give Nginx-ee a GitHub star : https://github.com/VirtuBox/nginx-ee"