Permalink
Browse files

* Added testing of the nginx binary.

  • Loading branch information...
1 parent 4375071 commit 503cf5e1286cda890ebba9f434fbbefe14c55e8e @perusio committed Jul 18, 2011
Showing with 33 additions and 31 deletions.
  1. +33 −31 nginx_ensite
View
64 nginx_ensite
@@ -2,33 +2,35 @@
### nginx_ensite --- Bash script to enable or disable a site in nginx.
-## Copyright (C) 2010 António P. P. Almeida <appa@perusio.net>
+### Copyright (C) 2010 António P. P. Almeida <appa@perusio.net>
-## Author: António P. P. Almeida <appa@perusio.net>
+### Author: António P. P. Almeida <appa@perusio.net>
-## Permission is hereby granted, free of charge, to any person obtaining a
-## copy of this software and associated documentation files (the "Software"),
-## to deal in the Software without restriction, including without limitation
-## the rights to use, copy, modify, merge, publish, distribute, sublicense,
-## and/or sell copies of the Software, and to permit persons to whom the
-## Software is furnished to do so, subject to the following conditions:
+### Permission is hereby granted, free of charge, to any person obtaining a
+### copy of this software and associated documentation files (the "Software"),
+### to deal in the Software without restriction, including without limitation
+### the rights to use, copy, modify, merge, publish, distribute, sublicense,
+### and/or sell copies of the Software, and to permit persons to whom the
+### Software is furnished to do so, subject to the following conditions:
-## The above copyright notice and this permission notice shall be included in
-## all copies or substantial portions of the Software.
+### The above copyright notice and this permission notice shall be included in
+### all copies or substantial portions of the Software.
-## Except as contained in this notice, the name(s) of the above copyright
-## holders shall not be used in advertising or otherwise to promote the sale,
-## use or other dealings in this Software without prior written authorization.
+### Except as contained in this notice, the name(s) of the above copyright
+### holders shall not be used in advertising or otherwise to promote the sale,
+### use or other dealings in this Software without prior written authorization.
-## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-## FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-## DEALINGS IN THE SOFTWARE.
+### THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+### IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+### FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+### THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+### LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+### FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+### DEALINGS IN THE SOFTWARE.
+## The nginx binary.
NGINX=$(which nginx)
+[ -x $NGINX ] || exit 0
## The paths for both nginx configuration files and the sites
## configuration files and symbolic link destinations.
@@ -73,18 +75,18 @@ fi
## action if possible. If not signal an error and exit.
case $ACTION in
ENABLE)
- if [ -r $SITE_AVAILABLE ]; then
- [ -h $SITE_ENABLED ] || ln -s $SITE_AVAILABLE $SITE_ENABLED
+ if [ -r $SITE_AVAILABLE ]; then
+ [ -h $SITE_ENABLED ] || ln -s $SITE_AVAILABLE $SITE_ENABLED
# Test for a well formed configuration.
- echo "Testing nginx configuration..."
- $NGINX -t && STATUS=0
- if [ $STATUS ]; then
- echo -n "site $1 has been enabled."
- echo "Run /etc/init.d/nginx reload to apply the changes."
- exit 0
- else
- exit 2
- fi
+ echo "Testing nginx configuration..."
+ $NGINX -t && STATUS=0
+ if [ $STATUS ]; then
+ echo -n "site $1 has been enabled."
+ echo "Run /etc/init.d/nginx reload to apply the changes."
+ exit 0
+ else
+ exit 2
+ fi
else
echo "Site configuration file $1 not found."
exit 3

0 comments on commit 503cf5e

Please sign in to comment.