Created
September 1, 2014 08:19
-
-
Save saksmt/ae8f51d7900b96969da8 to your computer and use it in GitHub Desktop.
Deploy script for symfony2
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/bash | |
# https://gist.github.com/saksmt/aac34dcfe0c5e94ce611 | |
source /usr/local/etc/colors.sh | |
function promt { | |
local questionAnswerVariants="["$green"Y"$clr"|"$red"n"$clr"]" | |
local ans="" | |
while true; do | |
echo -n $bright""$white""$1""$clr" "$questionAnswerVariants" " | |
read -n1 ans | |
if [[ ! ( $ans =~ [yYnN] || $ans == "" ) ]]; then | |
echo "" | |
echo "Sorry didn't understand, try again." | |
else | |
if [[ $ans != "" ]]; then | |
echo "" | |
fi | |
if [[ $ans =~ [yY] || $ans == "" ]]; then | |
answer=true | |
else | |
answer=false | |
fi | |
break | |
fi | |
done | |
} | |
if [[ ! -d "app" ]]; then | |
echo $error"Application directory is not found!" | |
echo "Did you forget to change your working directory(current: \""$PWD"\")?" | |
exit | |
fi; | |
if [[ -d ".svn" ]]; then | |
echo $info"Found \".svn\", assuming subversion directory." | |
promt "Update repository?" | |
if [[ $answer == true ]]; then | |
echo $info"Updating..." | |
svn up | |
echo $success"Updated!" | |
fi | |
fi; | |
if [[ -e "app/config/parameters.yml.dist" ]]; then | |
echo $info"Found \"parameters.yml.dist\""; | |
promt "Use it as \"parameters.yml\"?"; | |
if [[ $answer == true ]]; then | |
echo $info"Deploy with \"parameters.yml.dist\"..."; | |
rm app/config/parameters.yml &> /dev/null | |
mv app/config/parameters.yml.dist app/config/parameters.yml &> /dev/null | |
else | |
echo $info"Deploy with \"parameters.yml\"..."; | |
fi; | |
else | |
echo $warning"\"parameters.yml.dist\" is not found!"; | |
echo $info"Deploy with \"parameters.yml\"..."; | |
fi; | |
composer dump-autoload --optimize | |
app/console cache:clear --env=prod --no-debug; | |
app/console assetic:dump --env=prod --no-debug; | |
app/console assets:install --env=prod --no-debug; | |
chmod -R 777 app/{cache,logs} | |
echo $success"Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment