help:
echo "Usage: prj-site OPERATION NAME [type] "
echo "Options:"
+ echo " operation Operation on project; possible values:"
+ echo " create - creates project stubs according to type"
+ echo " enable"
+ echo " disable"
+ echo " remove"
echo " type Type of project; possible values:"
echo " cgi"
echo " drupal"
echo " symfony2"
-create: directories permissions vhost $(type)
+create: create-directories create-permissions create-vhost create-$(type) enable
cd ${name} && echo ${name} > README && git init && git add . && git commit -a -m 'Initial commit'
echo "[+] ${type} ${name} project has been created. Make sure that you have added: '${host}' to your /etc/hosts file"
+create-:
+
$(project_dir):
- echo "> Creating directory for project: ${name}"
+ echo "> Creating project directory: ${name}"
mkdir ${project_dir}
-directories: $(project_dir)
- echo "> Creating www directory ${project_dir}"
+create-directories: $(project_dir)
+ echo "> Creating directory: ${project_dir}/www"
mkdir ${project_dir}/www
-permissions: directories
+create-permissions: create-directories
echo "> Setting group permissions of {project}/www to www-data, need root permissions to do that."
sudo chgrp -R www-data ${project_dir}/www
echo "> Creating project's site configuration"
sudo cp ${apache_sites}/dummy.localhost ${apache_sites}/${host}
-vhost: ${apache_sites}/${host}
+create-vhost: ${apache_sites}/${host}
sudo sed -e "s/dummy/${name}/g" -i ${apache_sites}/${host}
sudo sed -e "s@/var/www/${name}@${project_dir}/www@" -i ${apache_sites}/${host}
sudo a2ensite ${host}
sudo service apache2 reload
-clean:
- echo "[+] Cleaning project"
+remove-directories:
+ echo "> Removing directory ${project_dir}/www"
+ sudo rm -r ${project_dir}/www
+ echo "> Removing directory: ${project_dir}"
+ sudo rm -r ${project_dir}
+
+remove-vhost:
+ if test -f ${apache_sites}/${host}; then \
+ echo "> Removing apache configuration file"; \
+ sudo rm ${apache_sites}/${host}; \
+ fi;
+
+enable: enable-${type}
+ echo "[+] Enabling ${name}"
+ if test -f /etc/apache2/sites-available/${host}; then \
+ echo "> Enabling project's vhost..."; \
+ sudo a2ensite ${host}; \
+ sudo service apache2 reload; \
+ else \
+ echo "> Enabling failed. Check your project configuration"; \
+ fi
+
+enable-:
+
+disable: disable-${type}
+ echo "[+] Disabling ${name}"
if test -h /etc/apache2/sites-enabled/${host}; then \
echo "> Disabling project's vhost..."; \
sudo a2dissite ${host}; \
sudo service apache2 reload; \
fi
-purge: clean purge-${type}
- echo "[+] Purging project"
- if test -e ${apache_sites}/${host}; then \
- echo "> Removing apache configuration file"; \
- sudo rm ${apache_sites}/${host}; \
- fi;
- if test -d ${project_dir}; then \
- echo "> Removing project directory"; \
- sudo rm -r ${project_dir}; \
- fi;
+disable-:
+
+purge: disable purge-${type} remove-vhost remove-directories
+ echo "[+] Project ${name} has been removed"
+
+purge-:
### Site types:
-cgi: directories
+cgi: create-directories
echo "[+] CGI installation begins..."
echo "AddHandler cgi-script cgi" > ${project_dir}/www/.htaccess
echo "Options +ExecCGI" >> ${project_dir}/www/.htaccess
-symfony2: directories vhost
+symfony2: create-directories create-vhost
echo "[+] Symfony installation begins..."
echo "> Recreating ${project_dir} for symfony2 specifics"
rm -r ${project_dir}
chmod -R 777 ${project_dir}/app/logs
sudo sed -e "s@${project_dir}/www@${project_dir}/web@" -i ${apache_sites}/${host}
-drupal: directories
+create-drupal: create-directories
echo "[+] Drupal installation begins..."
cd ${project_dir}/www && drush dl drupal
mv ${project_dir}/www/drupal*/* ${project_dir}/www/drupal*/.gitignore ${project_dir}/www/drupal*/.htaccess ${project_dir}/www/
echo "> Removing SQL database"
sudo mysql --defaults-file=/etc/mysql/debian.cnf -e "DROP DATABASE ${sql_user};"
-.PHONY: help clean purge
+.PHONY: help disable purge