SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/zsh
  2.  
  3. PrintUsage() {
  4.    echo "Usage: `basename $0` [-o log_file][-hv] <-aus> repositories"
  5.    echo "Options:"
  6.    echo "\ta: initialize, adds and publish the git repositories"
  7.    echo "\tu: update all repositories"
  8.    echo "\ts: get status of all repositories"
  9.    echo "\to: set file for log"
  10.    echo "\th: see this message"
  11.    echo "\tv: get software version"
  12.    exit 1
  13. }
  14.  
  15. while getopts "hvo:au" OPTION
  16. do
  17.     case $OPTION in
  18.         h)
  19.             PrintUsage
  20.             ;;
  21.         v)
  22.             echo "`basename $0` version 0.2"
  23.             exit
  24.             ;;
  25.         o)
  26.             ARQUIVO_LOG=$OPTARG
  27.             ;;
  28.         a)
  29.             DO_ALL=1
  30.             ;;
  31.         u)
  32.             DO_UPDATE=1
  33.             ;;
  34.         s)
  35.             SEE_STATUS=1
  36.             ;;
  37.         ?)
  38.             PrintUsage
  39.             ;;
  40.     esac
  41. done
  42. shift $((OPTIND-1))
  43.  
  44. if [ -z "$DO_ALL" ] && [ -z "$DO_UPDATE" ];
  45. then
  46.     PrintUsage
  47. fi
  48.  
  49. if [ "$ARQUIVO_LOG" ];
  50. then
  51.  
  52.     echo "Execucao iniciada em `date`." >> $ARQUIVO_LOG
  53.     for FILE in $*;
  54.     do
  55.         cd $FILE
  56.         if [ "$DO_ALL" = 1 ];
  57.         then
  58.             git init >> ../$ARQUIVO_LOG
  59.             git remote add origin git@github.com:patricksferraz/$FILE.git >> ../$ARQUIVO_LOG
  60.             git add * >> ../$ARQUIVO_LOG
  61.             git commit -m "initial commit" >> ../$ARQUIVO_LOG
  62.             git push origin master >> ../$ARQUIVO_LOG
  63.         fi
  64.         if [ "$DO_UPDATE" = 1 ];
  65.         then
  66.             git pull origin master >> ../$ARQUIVO_LOG
  67.             git push origin master >> ../$ARQUIVO_LOG
  68.         fi
  69.         cd ..
  70.     done
  71.  
  72. else
  73.  
  74.     echo "Execucao iniciada em `date`."
  75.     for FILE in $*;
  76.     do
  77.         cd $FILE
  78.         if [ "$DO_ALL" = 1 ];
  79.         then
  80.             git init
  81.             git remote add origin git@github.com:patricksferraz/$FILE.git
  82.             git add *
  83.             git commit -m "initial commit"
  84.             git push origin master
  85.         fi
  86.         if [ "$DO_UPDATE" = 1 ];
  87.         then
  88.             git pull origin master
  89.             git push origin master
  90.         fi
  91.         cd ..
  92.     done
  93.  
  94. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top