Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

first commit

  • Loading branch information...
commit 08fd0790db8df46710124cea6c54daeb8c7d692f 0 parents
@videlalvaro authored
Showing with 124 additions and 0 deletions.
  1. +21 −0 LICENSE.md
  2. +53 −0 README.md
  3. +50 −0 es.sh
21 LICENSE.md
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2011 Alvaro Videla
+
+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 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.
53 README.md
@@ -0,0 +1,53 @@
+# Enable Sites #
+
+## About ##
+
+Manage apache2 virtual hosts in Mac ala Ubuntu:
+
+ $ ./es.sh enable mysite
+ - Copying the sites_available/mysite.conf file
+ - Checking mysite.conf syntax
+ Syntax OK
+ - Restarting Apache2
+
+## Usage ##
+
+Clone this repository and give executing permission to the `es.sh` file.
+
+- Put your vhosts files in a folder called "sites_available"
+- Create a folder called "sites_enabled"
+- Add this line to your apache httpd.conf below the vhosts entry:
+
+ Include /Users/mrhyde/liip/sites_enabled/
+
+- Create the file `sites_available/mysite.conf` and setup your vhost there.
+
+To enable a site run:
+
+ ./es.sh enable mysite
+
+To disable a site run:
+
+ ./es.sh disable mysite
+
+## Configuration ##
+
+Modify the following scripts variables to match your setup:
+
+ APACHE_CTL=/opt/local/apache2/bin/apachectl
+ SITES_AVAILABLE_DIR=sites_available
+ SITES_ENABLED_DIR=sites_enabled
+
+## Extra ##
+
+If you don't want to be messing around with the `/etc/hosts` file do yourself a favor and install [Ghost](http://thechangelog.com/post/434045062/ghost-means-never-having-to-touch-etc-hosts-again)
+
+# NOTES #
+
+Only tested with apache2 installed using Mac Ports. This is a very poor's man solution to this problem. Feel free to improve it or to point me to a better one.
+
+This is my first Bash project so it might make you cry if you are a serious Bash user.
+
+## License ##
+
+See: LICENSE.md
50 es.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+cd `dirname $0`
+
+APACHE_CTL=/opt/local/apache2/bin/apachectl
+SITES_AVAILABLE_DIR=sites_available
+SITES_ENABLED_DIR=sites_enabled
+
+function restart_apache(){
+ echo "- Restarting Apache2"
+ sudo launchctl unload -w /Library/LaunchDaemons/org.macports.apache2.plist
+ sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist
+}
+
+function file_not_exist(){
+ echo "File $1 does not exists"
+}
+
+case $1 in
+
+"enable")
+ FILE=$SITES_AVAILABLE_DIR/$2.conf
+ DEST=$SITES_ENABLED_DIR/$2.conf
+ if [ -f $FILE ] ; then
+ echo "- Copying the $FILE file"
+ cp $FILE $DEST
+ echo "- Checking $2.conf syntax"
+ R=`$APACHE_CTL configtest 2>&1`
+ if [ "xSyntax OK" = "x$R" ] ; then
+ echo " "$R
+ restart_apache
+ else
+ rm $DEST
+ echo "- Configuration error: "$R
+ fi
+ else
+ file_not_exist $FILE
+ fi
+ ;;
+"disable")
+ FILE=$SITES_ENABLED_DIR/$2.conf
+ if [ -f $FILE ] ; then
+ echo "removing the $2.conf file"
+ rm $FILE
+ restart_apache
+ else
+ file_not_exist $FILE
+ fi
+ ;;
+esac
Please sign in to comment.
Something went wrong with that request. Please try again.