Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* Added creation of the sites-enabled directory.

  • Loading branch information...
commit c772c29c866a66badabd9c03166aedf34da6a432 1 parent f410035
@perusio authored
Showing with 27 additions and 23 deletions.
  1. +3 −1 README.org
  2. +24 −22 nginx_ensite
View
4 README.org
@@ -26,7 +26,9 @@ Note that the script assumes a specific file system topology for your
2. After running the script with =foobar= as argument: =nginx_ensite
foobar=. A symbolic link =/etc/nginx/sites-enabled/foobar ->
- /etc/nginx/sites-available/foobar= is created.
+ /etc/nginx/sites-available/foobar= is created. Note that if the
+ =/etc/nginx/sites-enabled= directory doesn't exist the script
+ creates it.
3. The script invokes =nginx -t= to test if the configuration is
correct. If the test fails no symbolic link is created and an error
View
46 nginx_ensite
@@ -1,32 +1,32 @@
#!/bin/bash
-# nginx_ensite --- Bash script to enable or disable a site in nginx.
+### 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.
NGINX=$(which nginx)
@@ -57,12 +57,14 @@ if [ $# -ne 1 ]; then
print_usage
else
SITE_AVAILABLE="$AVAILABLE_SITES_PATH/$1"
+ # Check if the sites-enabled directory exists. If not create it.
+ [ -d $ENABLED_SITES_PATH ] || mkdir -p $ENABLED_SITES_PATH
# If enabling the 'default' site then make sure that it's teh
# first to be loaded.
if [ $1 == "default" ]; then
SITE_ENABLED="$ENABLED_SITES_PATH/000-default"
else
- SITE_ENABLED="$ENABLED_SITES_PATH/$1"
+ SITE_ENABLED="$ENABLED_SITES_PATH/$1"
fi
fi
Please sign in to comment.
Something went wrong with that request. Please try again.