Advertisement
Gustavo_Inzunza

subida

Nov 2nd, 2017
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.44 KB | None | 0 0
  1. #!/bin/bash
  2. clear
  3. printf   "\n$(tput setaf 2)Cargando...        $(tput sgr 0)\n"
  4. echo "$(tput setaf 5)---------------------------------------"
  5. echo                                 =   0 ]
  6. echo "---------------------------------------$(tput sgr 0)"
  7. rama="vacia"
  8. tag="vacio"
  9. limpiar_cache=0
  10. migraciones=0
  11. if [[ $# -eq 0 ]]; then
  12.     echo "$(tput setaf 1)Se necesitan argumentos para la ejecución del archivo$(tput sgr 0)"
  13.     exit
  14. fi
  15. while [ ! $# -eq 0 ]
  16. do
  17.     case "$1" in
  18.         --rama | -r)
  19.             rama=$2
  20.             ;;
  21.         --tag | -t)
  22.             tag=$2
  23.             ;;
  24.         --limpiar-cache | -l)
  25.             limpiar_cache="true"
  26.             ;;
  27.         --ejecutar-migraciones | -em)
  28.             migraciones=1
  29.             ;;
  30.         --help | -h)
  31.             clear
  32.             printf   "\n$(tput setaf 2)Lista de opciones        $(tput sgr 0)\n"
  33. echo "$(tput setaf 5)+------------------------------+-------------------------------+"
  34.                echo "|Opción                        | Descripción                   |"
  35.                echo "+------------------------------+-------------------------------+"
  36.                echo "| -r  o --rama                 | rama a actualizar (*)         |"
  37.                echo "| -t  o --tag                  | tag a actualizar  (*)         |"
  38.                echo "| -l  o --limpiar-cache        | vuelve a compilar dependencias|"
  39.                echo "| -em o --ejecutar-migraciones | actualiza base de datos       |"
  40. echo "$(tput setaf 5)+----------------------+---------------------------------------+$(tput sgr 0)"
  41.             exit
  42.             ;;
  43.     esac
  44.     shift
  45. done
  46. if [[ $rama != "vacia" ]]; then
  47.     printf   "\n$(tput setaf 2)Actualizando rama $rama..$(tput sgr 0)\n"
  48.     echo "$(tput setaf 5)---------------------------------------"
  49.     echo [][]                            =   10 ]
  50.     echo "---------------------------------------$(tput sgr 0)"
  51.     output="$(git checkout -- . && git fetch && git checkout $rama && git pull origin $rama)"
  52. else
  53.     if [[ $tag != "vacio" ]]; then
  54.         printf   "\n$(tput setaf 2)Actualizando tag $tag..$(tput sgr 0)\n"
  55.         echo "$(tput setaf 5)---------------------------------------"
  56.         echo [][]                            =   10 ]
  57.         echo "---------------------------------------$(tput sgr 0)"
  58.         output="$(git checkout -- . && git fetch && git checkout $tag -b $tag)"
  59.     else
  60.         echo "$(tput setaf 1)No se ha ingresado tag ni rama$(tput sgr 0)"
  61.         exit
  62.     fi
  63. fi
  64. if [[ $? != 0 ]]; then
  65.     echo "$(tput setaf 1)Solucione los errores para continuar$(tput sgr 0)"
  66.     exit
  67. else
  68.     echo  "$(tput setaf 2)Actualización exitosa ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓$(tput sgr 0)"
  69.     echo  "$(tput setaf 2)Para la versión se requieren las siguientes configuraciones$(tput sgr 0)"
  70.     echo  "$(tput setaf 5)"
  71.     curl -X GET http://54.207.80.28/api-lebox/versiones?v=$tag | sed -e 's/[{}]/''/g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}'
  72.     echo "$(tput sgr 0)"
  73. fi
  74. printf   "\n$(tput setaf 2)Actualizando composer..$(tput sgr 0)\n"
  75. echo "$(tput setaf 5)---------------------------------------"
  76. echo [][][][]                        =   20 ]
  77. echo "---------------------------------------$(tput sgr 0)"
  78. composer update -o --no-dev
  79. if [[ $? != 0 ]]; then
  80.     echo "$(tput setaf 1)Solucione los errores para continuar$(tput sgr 0)"
  81.     exit
  82. else
  83.     echo  "$(tput setaf 2)Actualización exitosa ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓$(tput sgr 0)"
  84. fi
  85. if [[ $migraciones = 1 ]]; then
  86.     printf   "\n$(tput setaf 2)Actualizando base de datos...$(tput sgr 0)\n"
  87.     echo "$(tput setaf 5)---------------------------------------"
  88.     echo [][][][][][][][]               =   40 ]
  89.     echo "---------------------------------------$(tput sgr 0)"
  90.     php artisan migrate
  91.     if [[ $? != 0 ]]; then
  92.         echo "$(tput setaf 1)Solucione los errores para continuar$(tput sgr 0)"
  93.         exit
  94.     else
  95.         echo  "$(tput setaf 2)Actualización exitosa ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓$(tput sgr 0)"
  96.     fi
  97. fi
  98.  
  99.  
  100.  
  101. printf   "\n$(tput setaf 2)Actualizando npm...$(tput sgr 0)\n"
  102. echo "$(tput setaf 5)---------------------------------------"
  103. echo [][][][][][][][][]               =   50 ]
  104. echo "---------------------------------------$(tput sgr 0)"
  105. npm install
  106. if [[ $? != 0 ]]; then
  107.     echo "$(tput setaf 1)Solucione los errores para continuar$(tput sgr 0)"
  108.     exit
  109. else
  110.     echo  "$(tput setaf 2)Actualización exitosa ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓$(tput sgr 0)"
  111. fi
  112. printf   "\n$(tput setaf 2)Transpilando ES6, Vue y SASS...$(tput sgr 0)\n"
  113. echo "$(tput setaf 5)---------------------------------------"
  114. echo [][][][][][][][][][]           =   60 ]
  115. echo "---------------------------------------$(tput sgr 0)"
  116. npm run prod
  117. if [[ $? != 0 ]]; then
  118.     echo "$(tput setaf 1)Solucione los errores para continuar$(tput sgr 0)"
  119.     exit
  120. else
  121.     echo  "$(tput setaf 2)Transpilación exitosa ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓$(tput sgr 0)"
  122. fi
  123. if [[ $limpiar_cache = "true" ]]; then
  124.     printf   "\n$(tput setaf 2)Limpiando caché...$(tput sgr 0)\n"
  125.     echo "$(tput setaf 5)---------------------------------------"
  126.     echo [][][][][][][][][][][][]       =   80 ]
  127.     echo "---------------------------------------$(tput sgr 0)"
  128.     php artisan cache:clear
  129.     printf   "\n$(tput setaf 2)Limpiando caché de vistas...$(tput sgr 0)\n"
  130.     echo "$(tput setaf 5)---------------------------------------"
  131.     echo [][][][][][][][][][][][][]     =   90 ]
  132.     echo "---------------------------------------$(tput sgr 0)"
  133.     php artisan view:clear
  134.     printf   "\n$(tput setaf 2)Compilando dependencias...$(tput sgr 0)\n"
  135.     echo "$(tput setaf 5)---------------------------------------"
  136.     echo [][][][][][][][][][][][][      =   95 ]
  137.     echo "---------------------------------------$(tput sgr 0)"
  138.     composer dump-autoload
  139.     if [[ $? != 0 ]]; then
  140.     echo "$(tput setaf 1)Solucione los errores para continuar$(tput sgr 0)"
  141.         exit
  142.     else
  143.         echo  "$(tput setaf 2)Compilación exitosa ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓$(tput sgr 0)"
  144.     fi
  145.     printf   "\n$(tput setaf 2)Actualización finalizada...$(tput sgr 0)\n"
  146.     echo "$(tput setaf 5)---------------------------------------"
  147.     echo [][][][][][][][][][][][][]     =   100 ]
  148.     echo "---------------------------------------$(tput sgr 0)"
  149. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement