From: Rafał Długołęcki Date: Fri, 5 Jul 2013 13:20:31 +0000 (+0200) Subject: Renamed prj-create-site due to more general usage of script. X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=e6f25583c4a2f390f4817395cd35dac916a7bec5;p=prj-utils.git Renamed prj-create-site due to more general usage of script. Refactored code. Added hooks for makefile, so adding another options should be painless. Additional text about usage. --- diff --git a/prj-create-site b/prj-create-site deleted file mode 100755 index 884af6e..0000000 --- a/prj-create-site +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -op="$1" -name="$2" -type="$3" - -make name=$name type=$type -s -f ~/prj/prj-utils/prj-create-site-make $op - diff --git a/prj-site b/prj-site new file mode 100755 index 0000000..8cb13db --- /dev/null +++ b/prj-site @@ -0,0 +1,8 @@ +#!/bin/sh + +op="$1" +name="$2" +type="$3" + +make name=$name type=$type -s -f ~/prj/prj-utils/prj-site-make $op + diff --git a/prj-create-site-make b/prj-site-make similarity index 73% rename from prj-create-site-make rename to prj-site-make index 8abaf52..741783c 100755 --- a/prj-create-site-make +++ b/prj-site-make @@ -9,24 +9,31 @@ host = ${name}.localhost 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 @@ -34,39 +41,59 @@ ${apache_sites}/${host}: 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} @@ -78,7 +105,7 @@ symfony2: directories vhost 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/ @@ -106,4 +133,4 @@ purge-drupal: 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