Skip to content

Instantly share code, notes, and snippets.

@jeansf
Last active February 11, 2022 15:07
Show Gist options
  • Save jeansf/f948853bfe431946fa19c07b6ed3e316 to your computer and use it in GitHub Desktop.
Save jeansf/f948853bfe431946fa19c07b6ed3e316 to your computer and use it in GitHub Desktop.
PIX Shell Script Update
#!/bin/sh
echo ""
echo "╔════════════════════════════════════════════════════════════════════════════════════════╗"
echo "║ ██████╗ █████╗ ██████╗██╗ ██╗ ███████╗███╗ ██╗██████╗ ║"
echo "║ ██╔══██╗██╔══██╗██╔════╝██║ ██╔╝ ██╔════╝████╗ ██║██╔══██╗ ║"
echo "║ ██████╔╝███████║██║ █████╔╝█████╗█████╗ ██╔██╗ ██║██║ ██║ ║"
echo "║ ██╔══██╗██╔══██║██║ ██╔═██╗╚════╝██╔══╝ ██║╚██╗██║██║ ██║ ║"
echo "║ ██████╔╝██║ ██║╚██████╗██║ ██╗ ███████╗██║ ╚████║██████╔╝ ║"
echo "║ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝╚═════╝ ║"
echo "╚════════════════════════════════════════════════════════════════════════════════════════╝"
echo ""
echo "╔════════════════════════════════════════════════════════════════════════════════════════╗"
echo "╟────┤ Parando serviços ├────────────────────────────────────────────────────────────────╢"
echo "╚════════════════════════════════════════════════════════════════════════════════════════╝"
supervisorctl stop all
echo "╔════════════════════════════════════════════════════════════════════════════════════════╗"
echo "╟────┤ Atualizando dependências ├────────────────────────────────────────────────────────╢"
echo "╚════════════════════════════════════════════════════════════════════════════════════════╝"
if [ -f "bin/composer.phar" ]
then
if [[ ${GIT_TOKEN} && ${GIT_TOKEN-x} ]]; then
php bin/composer.phar config -g github-oauth.github.com ${GIT_TOKEN}
fi
php bin/composer.phar install
else
if [[ ${GIT_TOKEN} && ${GIT_TOKEN-x} ]]; then
composer config -g github-oauth.github.com ${GIT_TOKEN}
fi
composer install
fi
npm install
if [ -f "/var/www/html/src/Core/SystemBundle/package.json" ]
then
cd /var/www/html/src/Core/SystemBundle
npm install
cd /var/www/html
fi
for i in "$@"
do
case $i in
--gulp)
echo "╔════════════════════════════════════════════════════════════════════════════════════════╗"
echo "╟────┤ Gulp Deploy ├─────────────────────────────────────────────────────────────────────╢"
echo "╚════════════════════════════════════════════════════════════════════════════════════════╝"
./node_modules/gulp/bin/gulp.js deploy
;;
--phing=*)
echo "╔════════════════════════════════════════════════════════════════════════════════════════╗"
echo "╟────┤ Phing Deploy ├────────────────────────────────────────────────────────────────────╢"
echo "╚════════════════════════════════════════════════════════════════════════════════════════╝"
bin/phing deploy_prod -Denv.client=${i#*=} -Dexec.console=YES -Dexec.acl=setfacl -Dserver.user=apache -Dexec.production=YES
;;
*)
esac
done
echo "╔════════════════════════════════════════════════════════════════════════════════════════╗"
echo "╟────┤ Apagando cache ├──────────────────────────────────────────────────────────────────╢"
echo "╚════════════════════════════════════════════════════════════════════════════════════════╝"
if [ -f "bin/cachetool.phar" ]
then
php bin/cachetool.phar opcache:reset --cli
echo "OPCache reseted"
fi
php app/console cache:clear --env=prod
php app/console doctrine:cache:clear-m --env=prod
php app/console doctrine:cache:clear-r --env=prod
php app/console doctrine:cache:clear-query --env=prod
echo "╔════════════════════════════════════════════════════════════════════════════════════════╗"
echo "╟────┤ Instalando assets ├───────────────────────────────────────────────────────────────╢"
echo "╚════════════════════════════════════════════════════════════════════════════════════════╝"
php app/console assets:install web/ --symlink --env=prod
php app/console coresystem:assets:compile --env=prod --no-debug
php app/console assetic:dump --env=prod --no-debug
echo "╔════════════════════════════════════════════════════════════════════════════════════════╗"
echo "╟────┤ Aplicando permissões ├────────────────────────────────────────────────────────────╢"
echo "╚════════════════════════════════════════════════════════════════════════════════════════╝"
_USER=apache
_GROUP=apache
chown ${_USER}:${_GROUP} -R app/cache app/logs/ app/spool web/upload src/*/*/Resources/public
chmod 777 -R app/cache app/logs/ app/spool web/upload
if [ -f "/etc/crontab" ]
then
chown root:root /etc/crontab
chmod 644 /etc/crontab
fi
if [ -f "/var/spool/cron/root" ]
then
chown root:root /var/spool/cron/root
chmod 644 /var/spool/cron/root
fi
echo "╔════════════════════════════════════════════════════════════════════════════════════════╗"
echo "╟────┤ Iniciando serviços ├──────────────────────────────────────────────────────────────╢"
echo "╚════════════════════════════════════════════════════════════════════════════════════════╝"
supervisorctl start all
echo "╔════════════════════════════════════════════════════════════════════════════════════════╗"
echo "╚════════════════════════════════════════════════════════════════════════════════════════╝"
echo ""
#!/bin/sh
for i in "$@"
do
case $i in
-git|--git)
curl -sS "https://gist.githubusercontent.com/jeansf/f948853bfe431946fa19c07b6ed3e316/raw/git.sh?$(date +%s)" | bash -s -- "$@"
;;
--frontend)
curl -sS "https://gist.githubusercontent.com/jeansf/f948853bfe431946fa19c07b6ed3e316/raw/frontend.sh?$(date +%s)" | bash -s -- "$@"
;;
--backend)
curl -sS "https://gist.githubusercontent.com/jeansf/f948853bfe431946fa19c07b6ed3e316/raw/backend.sh?$(date +%s)" | bash -s -- "$@"
;;
*)
esac
done
#!/bin/sh
echo ""
echo "╔════════════════════════════════════════════════════════════════════════════════════════╗"
echo "║ ██████╗ ██╗████████╗ ║"
echo "║ ██╔════╝ ██║╚══██╔══╝ ║"
echo "║ ██║ ███╗██║ ██║ ║"
echo "║ ██║ ██║██║ ██║ ║"
echo "║ ╚██████╔╝██║ ██║ ║"
echo "║ ╚═════╝ ╚═╝ ╚═╝ ║"
echo "╚════════════════════════════════════════════════════════════════════════════════════════╝"
echo ""
branch="master"
currentBranch=$(git branch | grep \* | cut -d ' ' -f2)
for i in "$@"
do
case $i in
-b=*|--branch=*)
branch="${i#*=}"
;;
*)
esac
done
echo "╔════════════════════════════════════════════════════════════════════════════════════════╗"
echo "╟────┤ Atualizando código ├──────────────────────────────────────────────────────────────╢"
echo "╚════════════════════════════════════════════════════════════════════════════════════════╝"
echo ""
echo "▁▂▃▅▆▇ $branch ▇▆▅▃▂▁"
echo ""
if [ "$currentBranch" != "$branch" ]
then
git fetch origin $branch
git checkout $branch --force
fi
git pull origin $branch
echo "╔════════════════════════════════════════════════════════════════════════════════════════╗"
echo "╚════════════════════════════════════════════════════════════════════════════════════════╝"
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment