Simple EasyEngine for Mac

#!/bin/bash

# ee site create domain.com --php

#get params
DOMAIN=$2;

#write to sites-available
#cat >${DOMAIN}.conf <<EOF
cat >/usr/local/etc/nginx/sites-available/${DOMAIN}.conf <<EOF
server {
        listen 80;
        server_name ${DOMAIN};

        root /Users/$SUDO_USER/Sites/${DOMAIN}/htdocs;
        index index.php index.html index.htm;

        location / {
            try_files \$uri \$uri/ /index.php\$is_args\$args;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires 1y;
            log_not_found off;
        }

        location ~ \.php$ {
            try_files $uri /index.php =404;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
            include fastcgi_params;
        }
}
EOF

#change file ownership
chown $SUDO_USER:wheel /usr/local/etc/nginx/sites-available/${DOMAIN}.conf

#link to sites-enabled
ln -s /usr/local/etc/nginx/sites-available/${DOMAIN}.conf /usr/local/etc/nginx/sites-enabled/${DOMAIN}.conf

#make home directory
mkdir -p /Users/$SUDO_USER/Sites/${DOMAIN}/conf
mkdir -p /Users/$SUDO_USER/Sites/${DOMAIN}/logs
mkdir -p /Users/$SUDO_USER/Sites/${DOMAIN}/htdocs

#make index file
#printf "<h1>It Works!</h1>" >> /Users/$SUDO_USER/Sites/${DOMAIN}/htdocs/index.php

#change home ownership
chown -Rf $SUDO_USER:staff /Users/$SUDO_USER/Sites/${DOMAIN}

#add domain to /etc/hosts
printf "\n127.0.0.1 ${DOMAIN}" >> /etc/hosts

#reload nginx
nginx -s reload