BASH   16

update sh

Guest on 13th May 2022 01:51:36 AM

  1. #!/bin/bash
  2.  
  3. ARGS=$(getopt -o cbh --long composer,build -- "$@")
  4.  
  5. COMPOSER=0
  6. BUILD=0
  7.  
  8. usage() {
  9.   echo "Usage: update.sh [-c|--composer] [-b|--build] [-h|--help] -- <folder> <git_tag>"
  10.   exit 2;
  11. }
  12.  
  13. eval set -- $ARGS
  14. while :
  15. do
  16.   case $1 in
  17.     -c | --composer) COMPOSER=1 ; shift ;;
  18.     -b | --build)    BUILD=1    ; shift ;;
  19.     -h | --help)     usage ;;
  20.     --) shift; break ;;
  21.     *)  echo "Unexpected option: $1"; usage ;;
  22.   esac
  23. done
  24.  
  25. [[ ! ${#@} -eq 2 ]] && usage ;
  26.  
  27. FOLDER=$1
  28. GITTAG=$2
  29. DIR=/var/www/$FOLDER
  30.  
  31. [[ ! -d $DIR ]] && echo "No such directory $FOLDER exist." && exit 2;
  32.  
  33. echo -e "FOLDER=${FOLDER}\nCOMPOSER=${COMPOSER}\nBUILD=${BUILD}"
  34.  
  35. cd $DIR
  36.  
  37. git fetch --tags
  38. git checkout $GITTAG
  39.  
  40. [[ $COMPOSER -eq 1 ]] && docker run --rm --name=php -v $DIR:/code jayscgi/php:7.4 composer install
  41. [[ $BUILD -eq 1 ]] && build-vue

Raw Paste


Login or Register to edit or fork this paste. It's free.