Skip to content

Instantly share code, notes, and snippets.

@saksmt
Created September 1, 2014 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saksmt/ae8f51d7900b96969da8 to your computer and use it in GitHub Desktop.
Save saksmt/ae8f51d7900b96969da8 to your computer and use it in GitHub Desktop.
Deploy script for symfony2
#!/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