Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- clear
- printf "\n$(tput setaf 2)Cargando... $(tput sgr 0)\n"
- echo "$(tput setaf 5)---------------------------------------"
- echo = 0 ]
- echo "---------------------------------------$(tput sgr 0)"
- rama="vacia"
- tag="vacio"
- limpiar_cache=0
- migraciones=0
- if [[ $# -eq 0 ]]; then
- echo "$(tput setaf 1)Se necesitan argumentos para la ejecución del archivo$(tput sgr 0)"
- exit
- fi
- while [ ! $# -eq 0 ]
- do
- case "$1" in
- --rama | -r)
- rama=$2
- ;;
- --tag | -t)
- tag=$2
- ;;
- --limpiar-cache | -l)
- limpiar_cache="true"
- ;;
- --ejecutar-migraciones | -em)
- migraciones=1
- ;;
- --help | -h)
- clear
- printf "\n$(tput setaf 2)Lista de opciones $(tput sgr 0)\n"
- echo "$(tput setaf 5)+------------------------------+-------------------------------+"
- echo "|Opción | Descripción |"
- echo "+------------------------------+-------------------------------+"
- echo "| -r o --rama | rama a actualizar (*) |"
- echo "| -t o --tag | tag a actualizar (*) |"
- echo "| -l o --limpiar-cache | vuelve a compilar dependencias|"
- echo "| -em o --ejecutar-migraciones | actualiza base de datos |"
- echo "$(tput setaf 5)+----------------------+---------------------------------------+$(tput sgr 0)"
- exit
- ;;
- esac
- shift
- done
- if [[ $rama != "vacia" ]]; then
- printf "\n$(tput setaf 2)Actualizando rama $rama..$(tput sgr 0)\n"
- echo "$(tput setaf 5)---------------------------------------"
- echo [][] = 10 ]
- echo "---------------------------------------$(tput sgr 0)"
- output="$(git checkout -- . && git fetch && git checkout $rama && git pull origin $rama)"
- else
- if [[ $tag != "vacio" ]]; then
- printf "\n$(tput setaf 2)Actualizando tag $tag..$(tput sgr 0)\n"
- echo "$(tput setaf 5)---------------------------------------"
- echo [][] = 10 ]
- echo "---------------------------------------$(tput sgr 0)"
- output="$(git checkout -- . && git fetch && git checkout $tag -b $tag)"
- else
- echo "$(tput setaf 1)No se ha ingresado tag ni rama$(tput sgr 0)"
- exit
- fi
- fi
- if [[ $? != 0 ]]; then
- echo "$(tput setaf 1)Solucione los errores para continuar$(tput sgr 0)"
- exit
- else
- echo "$(tput setaf 2)Actualización exitosa ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓$(tput sgr 0)"
- echo "$(tput setaf 2)Para la versión se requieren las siguientes configuraciones$(tput sgr 0)"
- echo "$(tput setaf 5)"
- 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]}'
- echo "$(tput sgr 0)"
- fi
- printf "\n$(tput setaf 2)Actualizando composer..$(tput sgr 0)\n"
- echo "$(tput setaf 5)---------------------------------------"
- echo [][][][] = 20 ]
- echo "---------------------------------------$(tput sgr 0)"
- composer update -o --no-dev
- if [[ $? != 0 ]]; then
- echo "$(tput setaf 1)Solucione los errores para continuar$(tput sgr 0)"
- exit
- else
- echo "$(tput setaf 2)Actualización exitosa ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓$(tput sgr 0)"
- fi
- if [[ $migraciones = 1 ]]; then
- printf "\n$(tput setaf 2)Actualizando base de datos...$(tput sgr 0)\n"
- echo "$(tput setaf 5)---------------------------------------"
- echo [][][][][][][][] = 40 ]
- echo "---------------------------------------$(tput sgr 0)"
- php artisan migrate
- if [[ $? != 0 ]]; then
- echo "$(tput setaf 1)Solucione los errores para continuar$(tput sgr 0)"
- exit
- else
- echo "$(tput setaf 2)Actualización exitosa ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓$(tput sgr 0)"
- fi
- fi
- printf "\n$(tput setaf 2)Actualizando npm...$(tput sgr 0)\n"
- echo "$(tput setaf 5)---------------------------------------"
- echo [][][][][][][][][] = 50 ]
- echo "---------------------------------------$(tput sgr 0)"
- npm install
- if [[ $? != 0 ]]; then
- echo "$(tput setaf 1)Solucione los errores para continuar$(tput sgr 0)"
- exit
- else
- echo "$(tput setaf 2)Actualización exitosa ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓$(tput sgr 0)"
- fi
- printf "\n$(tput setaf 2)Transpilando ES6, Vue y SASS...$(tput sgr 0)\n"
- echo "$(tput setaf 5)---------------------------------------"
- echo [][][][][][][][][][] = 60 ]
- echo "---------------------------------------$(tput sgr 0)"
- npm run prod
- if [[ $? != 0 ]]; then
- echo "$(tput setaf 1)Solucione los errores para continuar$(tput sgr 0)"
- exit
- else
- echo "$(tput setaf 2)Transpilación exitosa ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓$(tput sgr 0)"
- fi
- if [[ $limpiar_cache = "true" ]]; then
- printf "\n$(tput setaf 2)Limpiando caché...$(tput sgr 0)\n"
- echo "$(tput setaf 5)---------------------------------------"
- echo [][][][][][][][][][][][] = 80 ]
- echo "---------------------------------------$(tput sgr 0)"
- php artisan cache:clear
- printf "\n$(tput setaf 2)Limpiando caché de vistas...$(tput sgr 0)\n"
- echo "$(tput setaf 5)---------------------------------------"
- echo [][][][][][][][][][][][][] = 90 ]
- echo "---------------------------------------$(tput sgr 0)"
- php artisan view:clear
- printf "\n$(tput setaf 2)Compilando dependencias...$(tput sgr 0)\n"
- echo "$(tput setaf 5)---------------------------------------"
- echo [][][][][][][][][][][][][ = 95 ]
- echo "---------------------------------------$(tput sgr 0)"
- composer dump-autoload
- if [[ $? != 0 ]]; then
- echo "$(tput setaf 1)Solucione los errores para continuar$(tput sgr 0)"
- exit
- else
- echo "$(tput setaf 2)Compilación exitosa ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓$(tput sgr 0)"
- fi
- printf "\n$(tput setaf 2)Actualización finalizada...$(tput sgr 0)\n"
- echo "$(tput setaf 5)---------------------------------------"
- echo [][][][][][][][][][][][][] = 100 ]
- echo "---------------------------------------$(tput sgr 0)"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement