From catherine stevens, 1 Year ago, written in Plain Text.
This paste will shuffle off the mortal coil in 1 Second.
This paste is a reply to from
- go back
Embed
Viewing differences between and Re: bash script for
  1. This clones a repo, creates a new branch, sets your remote up, updates the Centos 6/7 and Debian 8/9 platform versions as necessary, runs rake, runs git diff, and finally opens the file in Vim so you can double check.
  2.  
  3. TO RUN:
  4. chmod +x update-chefspec-platforms
  5. . ./update-chefspec-platforms [repo name you are cloning] [directory you want the repo to clone into]
  6.  
  7. The extra . in the front only works in bash and is necessary to be able to cd within the script. I haven't worked out how to get around it so it's usable outside of bash.
  8.  
  9.   1 #!/bin/bash
  10.   2
  11.   3 # change USERNAME to be your github username
  12.   4 USERNAME=csrs
  13.   5 repo="$1"
  14.   6 clonefolder="$2"
  15.   7
  16.   8 # $1 is repo name, $2 is destination folder
  17.   9 git clone git@github.com:osuosl-cookbooks/"$repo".git "$clonefolder"
  18.  10
  19.  11 cd "$clonefolder"/
  20.  12
  21.  13 git remote rename origin upstream
  22.  14 git checkout -b "$USERNAME"/update-chefspec-platforms
  23.  15
  24.  16 cd spec/
  25.  17
  26.  18 # Centos 6
  27.  19 sed -i "s/'6\.[0-9]'/'6.9'/g" spec_helper.rb
  28.  20
  29.  21 # Centos 7
  30.  22 sed -i "s/'7\.[0-9]\.[0-9]\{4\}'/'7.4.1708'/g" spec_helper.rb
  31.  23
  32.  24 # Debian 8
  33.  25 sed -i "s/'8\.[0-9]'/'8.10'/g" spec_helper.rb
  34.  26
  35.  27 # Debian 9
  36.  28 sed -i "s/'9\.[0-9]'/'9.3'/g" spec_helper.rb
  37.  29
  38.  30 cd ..
  39.  31 rake
  40.  32
  41.  33 echo "****** git diff ******"
  42.  34 git diff
  43.  35 vim spec_helper.rb
  44.