#!/bin/bash USER_NAME=$(whoami) PUB_NAME="pub" BASE_PATH="$( cd "$( dirname "$BASH_SOURCE[0]" )" && pwd)" PUB_BASE_PATH=$( cd "$BASE_PATH" && pwd | sed "s/\/home\/$USER_NAME\//\/home\/$PUB_NAME\//") MEDIA_DIRECTORY="media" PROJECT_PATH=`expr match "$BASE_PATH" '^\(\/[^\/]\+\/[^\/]\+\/[^\/]\+\/[^\/]\+\)'` #local.xml install #Creating symlink local.xml to local.xml.dev #if not existing local.xml.dev renaming local.xml to local.xml.dev function link_local_xml () { if [ ! -f "$BASE_PATH/app/etc/local.xml.dev" ] ; then echo -n 'local.xml.dev is not existing renaming local.xml...' mv $BASE_PATH/app/etc/local.xml $BASE_PATH/app/etc/local.xml.dev echo ' done!' fi if [ -h "$BASE_PATH/app/etc/local.xml" ] ; then echo -n '@local.xml is alredy existing. deleting it...' unlink $BASE_PATH/app/etc/local.xml echo ' done!' fi echo -n 'linking local.xml.dev...' ln -s $BASE_PATH/app/etc/local.xml.dev $BASE_PATH/app/etc/local.xml echo ' done!' } #local.xml end # media start function link_media_folder () { echo -n 'creating link to media folder' if [ -L "$BASE_PATH/$MEDIA_DIRECTORY" ] ; then echo -n 'media folder is existing unlinking, it...' unlink $BASE_PATH/$MEDIA_DIRECTORY echo ' done!' fi if [ ! -d "$PUB_BASE_PATH/$MEDIA_DIRECTORY" ] ; then echo -n 'creating pub/media...' mkdir -p $PUB_BASE_PATH/$MEDIA_DIRECTORY chmod -R 775 $PUB_BASE_PATH/$MEDIA_DIRECTORY echo 'Options -Indexes' > $PUB_BASE_PATH/$MEDIA_DIRECTORY/.htaccess echo ' done!' fi if [ -d "$BASE_PATH/$MEDIA_DIRECTORY" ] ; then echo -n 'dir exists' if [ "$(ls -A $BASE_PATH/$MEDIA_DIRECTORY)" ] ; then echo -n 'moving contend to pub/media...' mv $BASE_PATH/$MEDIA_DIRECTORY/* $PUB_BASE_PATH/$MEDIA_DIRECTORY chmod -R 775 $PUB_BASE_PATH/$MEDIA_DIRECTORY echo ' done!' fi echo -n "removing $USER_NAME/media..." rm -Rf $BASE_PATH/$MEDIA_DIRECTORY echo ' done!' fi echo 'making link to a pub/media...' ln -sT $PUB_BASE_PATH/$MEDIA_DIRECTORY $BASE_PATH/$MEDIA_DIRECTORY echo ' done!' } #echo Public link on $MEDIA_DIRECTORY created "$BASE_PATH/$MEDIA_DIRECTORY" # media end #------------------------------- set ignores ----------------------------- function set_svn_ignore () { if [ ! -d "$BASE_PATH/var" ] ; then echo -n 'var folder is not exist. creating...' mkdir "$BASE_PATH/var" chmod 777 var echo ' done with 777 permissions!' fi echo -n 'setting up svn ignore...' svn propset svn:ignore "*" var svn propset svn:ignore "media" . svn propset svn:ignore ".buildpath .cache .metadata .project .settings nbproject sitemap staging" ./ svn propset svn:ignore ".actionScriptProperties .flexProperties .project .settings" ./lib/flex/uploader svn propset svn:ignore ".actionScriptProperties .flexLibProperties .project .settings " ./lib/flex/varien svn propset svn:ignore 'config_sandbox' ./app svn propset svn:ignore "local.xml use_cache.ser " ./app/etc echo ' done!' } function svn_auto_add() { cd $BASE_PATH if svn_add_all ; then echo -n "all is cool" else echo -n "some error" fi } ######################################################################################### # Скрипт Створює симулінк для папки media, та додає в SVN ignone папки з кешем # # Скрипт потрібно запускати на проекті який вже доданий до SVN репозиторію ######################################################################################### case $1 in '--help') echo 'Usage: ./setup-magento.sh [options ...]' echo echo ' --help This Page' echo ' --test test dir paths' echo echo 'To Use this script you must place it to magento folder, whitch you have check out from SVN' echo 'ex. ~/public_html/magento_project/trunk' echo echo 'This script will make simulink to media folder of this project, and add to SVN ignore files' echo 'whitch not allow to be comited to SVN repository.' exit;; '--test') echo "BASE_PATH $BASE_PATH" echo "PUB_BASE_PATH $PUB_BASE_PATH" echo "PROJECT_PATH $PROJECT_PATH" exit;; esac link_local_xml link_media_folder set_svn_ignore echo '' echo "installing is finnished! " echo "all you need to continue is comite files to svn. you can do it only manualy for now: " echo "1) add all files to svn by CatZilla command 'svn_add_all'" echo "2) if svn returns prodlem like 'Inconsistent line ending style' change line ending by command 'unix2dos [file]' and go to 1)" echo "3) comite files to svn by command 'svn ci -m \" [message about adding files]\"' from base directory " echo ''