Advertisement
guilhermetb

Menu magento

Dec 3rd, 2018
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.21 KB | None | 0 0
  1. #!/bin/bash
  2. export NCURSES_NO_UTF8_ACS=1
  3. HEIGHT=20
  4. WIDTH=90
  5. CHOICE_HEIGHT=15
  6. BACKTITLE="Magento 2.3.0"
  7. TITLE="MENU"
  8. MENU="Escolha uma das opcoes:"
  9. binario="/usr/bin/php /var/www/html/magento2/bin/magento"
  10. systemctl="/bin/systemctl"
  11. sql="/usr/bin/mysql"
  12.  
  13. OPTIONS=(show    "Exibe current application mode"
  14.          prod    "Configura application mode: production"
  15.          dev     "Configura application mode: developer"
  16.          cache   "Realiza cache:flush e cache:clean"
  17.          restart "Restart servicos apache2 varnish redis mysql"
  18.          sql     "Conta quantidade de linhas na tabela cron_schedule"
  19.          perm    "Corrige permissoes no diretorio /var/www/html/magento2"
  20.          conf    "Exibe todas configuracoes"
  21.          setconf "Realiza alteracao nas configuracoes"
  22.          deploy  "Exclui arquivos static e cache / cache / deploy / permissions"
  23.          clean   "Exclui manualmente arquivos static e cache")
  24.  
  25. CHOICE=$(dialog --clear \
  26.                 --backtitle "$BACKTITLE" \
  27.                 --title "$TITLE" \
  28.                 --menu "$MENU" \
  29.                 $HEIGHT $WIDTH $CHOICE_HEIGHT \
  30.                 "${OPTIONS[@]}" \
  31.                 2>&1 >/dev/tty)
  32.  
  33. clear
  34. case $CHOICE in
  35.         show)
  36.             echo -e "\033[44;1;37m Exibe current application mode\033[0m"
  37.             $binario deploy:mode:show
  38.             ;;
  39.         prod)
  40.             echo -e "\033[44;1;37m Alterando para production mode\033[0m"
  41.             $binario deploy:mode:set production
  42.             ;;
  43.         dev)
  44.             echo -e "\033[44;1;37m Alterando para developer mode\033[0m"
  45.             $binario deploy:mode:set developer
  46.             ;;
  47.         cache)
  48.             echo -e "\033[44;1;37m Realizando cache:flush\033[0m"
  49.             $binario cache:flush
  50.             echo -e "\033[44;1;37m Realizando cache:clean\033[0m"
  51.             $binario cache:clean
  52.             ;;
  53.         restart)
  54.             echo -e " \033[42;1;37m[OK]\033[0m" Restart Nginx
  55.             $systemctl restart nginx
  56.             echo -e " \033[42;1;37m[OK]\033[0m" Restart PHP7.2-FPM
  57.             $systemctl restart php7.2-fpm
  58.             echo -e " \033[42;1;37m[OK]\033[0m" Restart Varnish
  59.             $systemctl restart varnish
  60.             echo -e " \033[42;1;37m[OK]\033[0m" Restart Redis
  61.             $systemctl restart redis-server
  62.             echo -e " \033[42;1;37m[OK]\033[0m" Restart Mysql
  63.             $systemctl restart mysql
  64.             ;;
  65.         sql)
  66.             echo -e "\033[44;1;37m Resultado do select\033[0m"
  67.             $sql -u USERMYSQL -p'PASSMYSQL' -e 'select count(*) from cron_schedule;' magento
  68.             ;;
  69.         perm)
  70.             echo -e "\033[44;1;37m Corrigindo as permissoes diretorio/arquivos\033[0m"
  71.             cd /var/www/html/magento2
  72.             echo "[*] Alterando user:group"
  73.             chown www-data:www-data -R *
  74.             echo "[*] Alterando permissao arquivos para 644"
  75.             find . -type f -exec chmod 644 {} \;
  76.             echo "[*] Alterando permissao diretorios para 755"
  77.             find . -type d -exec chmod 755 {} \;
  78.             echo "[*] Permissao 777 /var"
  79.             find ./var -type d -exec chmod 777 {} \;
  80.             echo "[*] Permissao 777 diretorios /pub/media"
  81.             find ./pub/media -type d -exec chmod 777 {} \;
  82.             echo "[*] Permissao 777 diretorios /pub/static"
  83.             find ./pub/static -type d -exec chmod 777 {} \;
  84.             echo "[*] Permissao 777 /app/etc"
  85.             chmod 777 ./app/etc
  86.             echo "[*] Permissao 644 para todos xml em /app/etc"
  87.             chmod 644 ./app/etc/*.xml
  88.             echo "[*] Permissão 777 para diretorio /generated"
  89.             chmod 777 ./generated
  90.             ;;
  91.         conf)
  92.             echo -e "\033[44;1;37m Exibindo configuracoes\033[0m"
  93.             $binario config:show
  94.             ;;
  95.         setconf)
  96.             PARAM=$(dialog --stdout --inputbox 'Digite <parametro> <1/0>' 0 0)
  97.             clear
  98.             echo -e "\033[44;1;37m Alterando parametro\033[0m"
  99.             $binario config:set $PARAM
  100.             ;;
  101.         deploy)
  102.             echo -e "\033[44;1;37m Excluindo arquivos cache e static\033[0m"
  103.             echo -e "[*] Excluindo arquivos diretorio /var/view_preprocessed/*"
  104.             rm -rf /var/www/html/magento2/var/view_preprocessed/*
  105.             echo -e "[*] Excluindo arquivos diretorio /var/page_cache/*"
  106.             rm -rf /var/www/html/magento2/var/page_cache/*
  107.             echo -e "[*] Excluindo arquivos diretorio /pub/static/*"
  108.             rm -rf /var/www/html/magento2/pub/static/*
  109.             echo -e "[*] Excluindo arquivos diretorio /var/cache/*"
  110.             rm -rf /var/www/html/magento2/var/cache/*
  111.             echo -e "\033[44;1;37m Realizando cache:flush\033[0m"
  112.             $binario cache:flush
  113.             echo -e " "
  114.             echo -e "\033[44;1;37m Realizando cache:clean\033[0m"
  115.             $binario cache:clean
  116.             echo -e " "
  117.             echo -e "\033[44;1;37m Realizando deploy\033[0m"
  118.             $binario setup:static-content:deploy
  119.             echo -e " "
  120.             echo -e "\033[44;1;37m Corrigindo as permissoes diretorio/arquivos\033[0m"
  121.             cd /var/www/html/magento2
  122.             echo "[*] Alterando user:group"
  123.             chown www-data:www-data -R *
  124.             echo "[*] Alterando permissao arquivos para 644"
  125.             find . -type f -exec chmod 644 {} \;
  126.             echo "[*] Alterando permissao diretorios para 755"
  127.             find . -type d -exec chmod 755 {} \;
  128.             echo "[*] Permissao 777 /var"
  129.             find ./var -type d -exec chmod 777 {} \;
  130.             echo "[*] Permissao 777 diretorios /pub/media"
  131.             find ./pub/media -type d -exec chmod 777 {} \;
  132.             echo "[*] Permissao 777 diretorios /pub/static"
  133.             find ./pub/static -type d -exec chmod 777 {} \;
  134.             echo "[*] Permissao 777 /app/etc"
  135.             chmod 777 ./app/etc
  136.             echo "[*] Permissao 644 para todos xml em /app/etc"
  137.             chmod 644 ./app/etc/*.xml
  138.             echo "[*] Permissão 777 para diretorio /generated"
  139.             chmod 777 ./generated
  140.             echo -e " "
  141.             echo -e "\033[44;1;37m Restart servicos\033[0m"
  142.             echo -e " \033[42;1;37m[OK]\033[0m" Restart Apache2
  143.             $systemctl restart apache2
  144.             echo -e " \033[42;1;37m[OK]\033[0m" Restart Varnish
  145.             $systemctl restart varnish
  146.             echo -e " \033[42;1;37m[OK]\033[0m" Restart Redis
  147.             $systemctl restart redis-server
  148.             echo -e " \033[42;1;37m[OK]\033[0m" Restart Mysql
  149.             $systemctl restart mysql
  150.             ;;
  151.         clean)
  152.             echo -e "\033[44;1;37m Excluir manualmente arquivos static e cache\033[0m"
  153.             echo -e "[*] Excluindo arquivos diretorio /var/view_preprocessed/*"
  154.             rm -rf /var/www/html/magento2/var/view_preprocessed/*
  155.             echo -e "[*] Excluindo arquivos diretorio /var/page_cache/*"
  156.             rm -rf /var/www/html/magento2/var/page_cache/*
  157.             echo -e "[*] Excluindo arquivos diretorio /pub/static/*"
  158.             rm -rf /var/www/html/magento2/pub/static/*
  159.             echo -e "[*] Excluindo arquivos diretorio /var/cache/*"
  160.             rm -rf /var/www/html/magento2/var/cache/*
  161.             ;;
  162. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement