-
Notifications
You must be signed in to change notification settings - Fork 4
/
.grrc
147 lines (118 loc) · 5.32 KB
/
.grrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
function gpgrep() {
find . -type f -name '*.gpg' -exec sh -c "gpg -q -d --no-tty \"{}\" | grep -InH --color=auto --label=\"{}\" $*" \;
}
# legacy line? testing removing for new laptop setup and not linux
# export IPSEC_SECRETS_FILE=/etc/ipsec.secrets
export KEY_SUFFIX=grandrounds.com
# Grand rounds stuff
export GR_HOME=${HOME}/src
export GR_USERNAME=andrew.ray
if [ -d "$GR_HOME" ]; then
pathadd "${GR_HOME}/engineering/bin"
for file in ${GR_HOME}/engineering/bash/*.sh; do
source "$file"
done
fi
# For asdf
if type "asdf" > /dev/null 2>&1; then
# Apparently this is the new right way to source asdf, based on
# https://github.com/asdf-vm/asdf/issues/1103#issuecomment-1093094933
# source "$(brew --prefix asdf)/libexec/asdf.sh"
# Below, we inline the above brew prefix calls for shell startup speed
source "/usr/local/opt/asdf/libexec/asdf.sh"
else
echo 'asdf not found'
echo 'Suggest: brew install asdf'
fi
function releaseCommits() {
git fetch --all
# Find the latest two non-smoke non-test release branches
latestBranches=$(git branch -a | grep -vo '/smoke/' | grep -vo '/test/' | grep -o '.*rc/branch/\d\{4\}-.\+' | sort -r | head -n 2)
currentReleaseBranch=$(echo "$latestBranches" | head -n 1 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
lastReleaseBranch=$(echo "$latestBranches" | tail -n 1 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
# Show only the merge commits in this branch
gitCommand="git log --first-parent master --pretty=format:'%Cred%h%Creset - %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit ${currentReleaseBranch}..${lastReleaseBranch}"
echo "Executing:"
echo " ${gitCommand}"
echo
git log --first-parent master --pretty=format:'%Cred%h%Creset - %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit "${currentReleaseBranch}..${lastReleaseBranch}"
# Strip out remote/ prefix of branch name to pass to github link
currentReleaseBranchWithoutRemote=$(echo "$currentReleaseBranch" | sed -E 's/remotes\/[^\/]+\///')
lastReleaseBranchWithoutRemote=$(echo "$lastReleaseBranch" | sed -E 's/remotes\/[^\/]+\///')
echo
echo "You can see these commits on Github:"
echo " https://github.com/ConsultingMD/jarvis/compare/${lastReleaseBranchWithoutRemote}...${currentReleaseBranchWithoutRemote}"
}
function jgrep() {
#bundle exec rake routes > ~/dev/rake-routes
cat ~/dev/rake-routes | grep -i "$1"
}
# Salesforce stuff
[ -f ~/.salesforcerc ] && source ~/.salesforcerc
# An alias to dump globalprotect routes so you can use strongswan
alias vpn_fix='vpn_fix'
alias vpnfix='vpn_fix'
# and to turn globalprotect back on when you're done
alias gpon='launchctl load /Library/LaunchAgents/com.paloaltonetworks.gp.pangp*'
# v1.0 by Marty 04/15/2020
# Script to dump GP and routes so Strongswan will work
function vpn_fix() {
echo -e "${LP}Dumping Global Protect launch agents${NC}"
launchctl unload /Library/LaunchAgents/com.paloaltonetworks.gp.pangp*
echo -e "${LP}Dropping an StrongSwan VPN connections${NC}"
sudo ipsec down production
echo -e "${LP}Dropping old Global Protect routes${NC}"
sudo route delete 10.191/16
echo -e "${LP}Set your AWS Params and VPNme now${NC}"
echo "When you're done and want to reenable GlobalProtect, type 'gpon'"
}
schedule_production_deploy() {
local last_production_commit="$1"
local time_to_deploy="$2"
git fetch --all
local master_commit
master_commit=$(git rev-parse origin/master)
local commits
commits=$(gl --merges "$last_production_commit".."$master_commit")
commits=$(echo "$commits" | sed "s/Megan Bananzadeh/<@megan.bananzadeh>/g")
commits=$(echo "$commits" | sed "s/Delphine Foo-Matkin/<@delphine.foo-matkin>/g")
commits=$(echo "$commits" | sed "s/Andy Ray/<@andrew.ray>/g")
commits=$(echo "$commits" | sed "/Merge branch 'master'/d")
commits=$(echo "$commits" | sed "s/^/• /g")
local merge_count
merge_count=$(echo "$commits" | wc -l | sed 's/ *$//g')
local message
message=":redlight: :clock3: A *Production deploy has been scheduled for ${time_to_deploy} PT today.* Say '<@placebo> pause deploy' to cancel\\n\\nThe difference between production (${last_production_commit}) and UAT (${master_commit}) is *${merge_count} stories:*\\n\\n${commits}"
go_tell_placebo "$message"
}
[ -f "$HOME/.jiracreds" ] && source "$HOME/.jiracreds"
[ -f "$HOME/.gitaccesstoken" ] && source "$HOME/.gitaccesstoken"
# From BOBs repo
alias bazel=bazelisk
# From BOBs repo
export GO111MODULE=on
export GOPROXY=direct
export GOPRIVATE=github.com/ConsultingMD
export GOPATH="${HOME}/go"
export GOBIN="${GOPATH}/bin"
pathadd "${GOBIN}"
alias stopgp='launchctl unload /Library/LaunchAgents/com.paloaltonetworks.gp.pangp*'
alias startgp='launchctl load /Library/LaunchAgents/com.paloaltonetworks.gp.pangp*'
# For aws-environment
export AWS_DEFAULT_ROLE=developer
function go_tell_placebo {
local text_to_post=$1
# This is one way to nest double quotes in bash :(
local dqt='"'
curl -X POST -H 'Content-type: application/json' \
--data "{${dqt}text${dqt}:${dqt}${text_to_post}${dqt}}" \
`cat ~/.placebo-webhook`
}
# Auth0 bearer token is in closed source
# Maven
export M2_HOME="/Users/andrew.ray/apache-maven-3.8.6/bin"
pathadd "$M2_HOME"
# Java
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home"
pathadd "${JAVA_HOME}/bin"