Created
November 4, 2013 15:48
-
-
Save muhittin/7304579 to your computer and use it in GitHub Desktop.
Setup shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
hosts_config(){ | |
hosts_file=/private/etc/hosts | |
echo "\n127.0.0.1 $1\n">>$hosts_file | |
echo "Hosts file was updated." | |
} | |
apache_config(){ | |
site_name=$1 | |
full_dir=$2 | |
setup=$3 | |
echo "Domain extension: [dev]" | |
read extension | |
if [ ! $extension ] | |
then | |
extension="dev" | |
fi | |
conf_file="/private/etc/apache2/extra/httpd-vhosts.conf" | |
site_url="$sitename.$extension" | |
echo "Domain name saving as $site_url " | |
echo "Sub-Public folder is exist? [public,web]: [web]" | |
read folder_extend | |
if [ ! $folder_extend ] | |
then | |
folder_extend="web" | |
fi | |
if [ $folder_extend ] | |
then | |
full_dir=$full_dir"/"$folder_extend | |
fi | |
conf="\n | |
<VirtualHost *:80>\n | |
\t ServerName $site_url\n | |
\t ServerAlias $site_url\n | |
\t DocumentRoot \"$full_dir\"\n | |
\t ErrorLog \"/private/var/log/apache2/$sitename.error.log\"\n | |
\t CustomLog \"/private/var/log/apache2/$sitename.access.log\" common\n | |
\t <Directory \"$full_dir\">\n | |
\t\t AllowOverride All\n | |
\t\t Order allow,deny\n | |
\t\t allow from all\n | |
\t </Directory>\n | |
</VirtualHost>\n | |
" | |
echo $conf>>$conf_file | |
echo "Conf settings writed in $conf_file file." | |
apachectl graceful | |
echo "Apache restarted." | |
hosts_config $site_url | |
} | |
parameters_init(){ | |
site_name=$1 | |
full_dir=$2 | |
echo "Enter database host [localhost]:" | |
read database_host | |
if [ ! $database_host ] | |
then | |
database_host="localhost" | |
fi | |
echo "Enter database name [$site_name]:" | |
read database_name | |
if [ ! $database_name ] | |
then | |
database_name=$site_name | |
fi | |
echo "Enter database username [root]:" | |
read database_username | |
if [ ! $database_username ] | |
then | |
database_username="root" | |
fi | |
echo "Enter database password []:" | |
read database_password | |
if [ ! $database_password ] | |
then | |
database_password="" | |
fi | |
echo "Enter default_locale [tr]:" | |
read default_locale | |
if [ ! $default_locale ] | |
then | |
default_locale="tr" | |
fi | |
tmp="parameters:\n | |
database_driver: pdo_mysql\n | |
database_host: $database_host\n | |
database_port: null\n | |
database_name: $database_name\n | |
database_user: $database_username\n | |
database_password:$database_password\n | |
mailer_transport: smtp\n | |
mailer_host: smtp.mandrillapp.com\n | |
mailer_user: [email protected]\n | |
mailer_password: quDAHf1v9Ca6MU88O8_dVQ\n | |
mailer_port: 587\n | |
locale: $default_locale\n | |
secret: c1fd210fc57dfd2bd3910d3fec416e7db1\n | |
database_path: null\n | |
available_locales:\n | |
tr: Türkçe\n | |
web_folder: $full_dir/" | |
echo $tmp>>$full_dir/../app/config/parameters_dev.yml | |
} | |
composer_init(){ | |
cd $1/../ | |
mkdir -p app/cache | |
mkdir -p app/logs | |
mkdir -p web/uploads | |
mkdir -p web/thumbnails | |
php composer.phar self-update | |
php composer.phar install | |
} | |
doctrine_generate(){ | |
php app/console doctrine:database:create | |
php app/console doctrine:schema:update --force | |
} | |
base_setup(){ | |
git clone [email protected]:muhittin/base.git $full_dir | |
echo "Base clone complete" | |
apache_config $1 $2 "y" | |
chmod -R 777 $full_dir | |
echo "Base repository cloned your local system." | |
parameters_init $sitename $full_dir | |
composer_init $full_dir | |
doctrine_generate | |
echo "\nCONGRULATIONS!!! Nice pic bro :)" | |
} | |
normal_setup(){ | |
if [ -d $full_dir ] | |
then | |
echo "Directory was not created because $full_dir directory is exist." | |
fi | |
if [ ! -d $full_dir ] | |
then | |
echo "$full_dir creating." | |
mkdir -p $full_dir | |
fi | |
chmod -R 777 $full_dir | |
apache_config $1 $2 "n" | |
echo "Congratulations! $sitename activated." | |
} | |
echo 'Enter domain name:' | |
read sitename | |
full_dir="/Users/macbookpro/Local/$sitename" | |
echo "Are you want clone muhittin/base repository ? [y|n]" | |
read s | |
if [ ! $s ] | |
then | |
s='n' | |
fi | |
if [ $s = "n" ] | |
then | |
echo "Normal setup starting..." | |
normal_setup $sitename $full_dir | |
elif [ $s = "y" ] | |
then | |
echo "Base repository setup starting..." | |
base_setup $sitename $full_dir | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@muhittin şurada bir hata var. iki noktadan sonra boşluk olmazsa, composer patlıyor.