# Backup Directories DB_BACKUP_DIR="project-db" FILES_BACKUP_DIR="project-files" # Misc PUB_NAME="pub" PUB_PUBLIC_HTML="/home/$PUB_NAME/public_html" THUMBNAILS_DIRECTORY="thumbnails" FILES_DIRECTORY="userfiles" REPOSITORY_URL="http://svn.adaptainc.com" USER_NAME=$(whoami) BASE_PATH=`pwd | xargs dirname` WWW_PATH="$BASE_PATH/www" PROJECT_PATH=`expr match "$BASE_PATH" '^\(\/[^\/]\+\/[^\/]\+\/[^\/]\+\/[^\/]\+\)'` PROJECT_NAME=`echo $PROJECT_PATH | xargs basename` PUB_BASE_PATH=$(pwd | xargs dirname | sed "s/\/home\/$USER_NAME\//\/home\/pub\//") BRANCHE_PATH=$(echo $BASE_PATH | sed "s/\/home\/$USER_NAME\/public_html\/$PROJECT_NAME\///") DB_BACKUP_PATH=$PROJECT_PATH/$DB_BACKUP_DIR/$BRANCHE_PATH ######################################################################################################################## # FUNCTIONS # ######################################################################################################################## # cecho colors CL_DEFAULT='\E[0m' CL_BLACK='\E[30m' CL_RED='\E[31m' CL_GREEN='\E[32m' CL_YELLOW='\E[33m' CL_BLUE='\E[34m' CL_WHILE='\E[37m' cecho () { local message=${1:-''} local color=${2:-$CL_WHILE} echo -ne "$color" echo -ne "$message" echo -ne $CL_DEFAULT return } initTempSymlink() { if [ -L "$BASE_PATH/site/tmp/$1" ] ; then unlink $BASE_PATH/site/tmp/$1 fi if [ -d "$BASE_PATH/site/tmp/$1" ] ; then rm -Rf $BASE_PATH/site/tmp/$1 fi if [ ! -d "$PUB_BASE_PATH/site/tmp/$1" ] ; then mkdir -p $PUB_BASE_PATH/site/tmp/$1 fi ln -sT $PUB_BASE_PATH/site/tmp/$1 $BASE_PATH/site/tmp/$1 } setPermissions() { dirInfo=$(stat --printf='dirPermissions="%a" ; dirOwner="%U"' "$1") eval $dirInfo # get user and group bits dirPermissions=$(echo "$dirPermissions" | cut -b 1-2) if [ "77" != "$dirPermissions" ] ; then if [ "$USER_NAME" != "$dirOwner" ] ; then cecho "WARNING: Can not change permissions for directory '$1'. Direcroty owner '$dirOwner'.\n" $CL_YELLOW else chmod 777 "$1" 2>/dev/null fi fi }