Skip to content

Instantly share code, notes, and snippets.

@mehdichaouch
Last active July 26, 2016 09:19
Show Gist options
  • Save mehdichaouch/7a72dc2f2d54cdb3b235 to your computer and use it in GitHub Desktop.
Save mehdichaouch/7a72dc2f2d54cdb3b235 to your computer and use it in GitHub Desktop.
Script to moves caches and logs in project/var/* (like SF3 new structure)
#!/bin/bash
timestamp=`date +"%Y%m%d-%H%M%S"`
current_dir=$(pwd)
script_dir=$(cd "$(dirname "$0")"; pwd)
project_dir="$script_dir/../../"
current_date=$(date +%Y%m%d-%H%M%S)
echo "Moves of caches and log in project/var/* (like SF3 new structure)"
cd $project_dir
if [ ! -d "var" ]; then
mkdir var
fi
mkdir -p var/cache var/logs
chown -R www-data:www-data var/cache/ var/logs/
# code for new cache and log location
code_snippet="\\
public function getCacheDir()\\
{\\
return \$this->rootDir . '\/..\/..\/..\/var\/cache\/' . \$this->environment;\\
}\\
\\
public function getLogDir()\\
{\\
return \$this->rootDir . '\/..\/..\/..\/var\/' . \$this->environment . '\/logs\/';\\
}\\
}"
sed -i "s/^}$/${code_snippet}/g" "$script_dir/../app/AppKernel.php"
echo "DONE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment