Browse Source

add create-site

Nathaniel van Diepen 9 years ago
parent
commit
c49a3c9cc2
2 changed files with 38 additions and 0 deletions
  1. 24 0
      create-site
  2. 14 0
      default.site.conf

+ 24 - 0
create-site

@@ -0,0 +1,24 @@
+#!/bin/bash
+if [[ $EUID -ne 0 ]]; then # Force root
+	exec sudo $0 "$@";
+fi;
+if [[ "$1" == "" ]];then
+	echo "Usage: $0 site [target]";
+	exit 1;
+fi;
+site=$(basename $1);
+ROOT=$(dirname $(realpath $0));
+if [[ "$2" == "" ]];then
+	echo "Creating site directory";
+	mkdir -p /var/www/$site;
+else
+	echo "Creating site symlink";
+	ln -s "$2" "/var/www/$site";
+fi;
+if [[ ! -f /etc/apache2/sites-available/$site.conf ]]; then
+	echo "Creating site config";
+	cp $ROOT/default.site.conf /etc/apache2/sites-available/$site.conf;
+	sed -i "s/__SITE__/$site/" /etc/apache2/sites-available/$site.conf;
+fi;
+a2ensite $site;
+service apache2 reload;

+ 14 - 0
default.site.conf

@@ -0,0 +1,14 @@
+<VirtualHost *:80>
+	ServerName __SITE__
+	DocumentRoot /var/www/__SITE__
+	<Directory /var/www/__SITE__>
+		Options +ExecCGI +Indexes +FollowSymLinks +MultiViews
+		AllowOverride All
+		RewriteEngine On
+		Order allow,deny
+		allow from all
+	</Directory>
+	ErrorLog ${APACHE_LOG_DIR}/error.log
+	CustomLog ${APACHE_LOG_DIR}/access.log combined
+	ServerAdmin [email protected]
+</VirtualHost>