-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbash_aliases
More file actions
228 lines (208 loc) · 8.38 KB
/
bash_aliases
File metadata and controls
228 lines (208 loc) · 8.38 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/bin/bash
alias df='df -h -x squashfs -x overlay | grep -vE " /snap|^tmpfs|^shm"'
alias tmux=byobu
alias termbin='nc termbin.com 9999'
alias tree="tree -I '__pycache__|*.egg-info'"
alias wkc='watch -n0.5 kubectl'
. ~/.devhelpers/git-helpers
. ~/.devhelpers/bzr-helpers
. ~/.devhelpers/juju-helpers
. ~/.devhelpers/go-helpers
if [[ -e /usr/share/virtualenvwrapper/virtualenvwrapper.sh ]]; then
. /usr/share/virtualenvwrapper/virtualenvwrapper.sh
fi
alias open='xdg-open'
alias du='du -bhs'
alias ip='ip -c'
unset -f nova
function nova() {
. ~/.config/canonistack/novarc_lcy01
/usr/bin/nova "$@"
}
unset -f glance
function glance() {
. ~/.config/canonistack/novarc_lcy01
/usr/bin/glance "$@"
}
function jres() {
services="$(juju pprint | sed -e 's/^- \([^\/]*\).*/\1/')"
machines="$(juju status | grep machine: | sed -e 's/.*"\(.*\)"/\1/' | sort | uniq)"
for s in $services; do
juju remove-service $s
done
for m in $machines; do
juju remove-machine --force $m
done
~/bin/juju-machine-count > ~/.juju/.machine-count
}
unset -f jv
function jv() {
# Select juju version using update-alternatives
version=$1
juju_alternatives=($(update-alternatives --list juju))
selected=${juju_alternatives[$(expr $version - 1)]}
sudo update-alternatives --set juju $selected
}
#alias cfendpoint='juju status haproxy | grep public-address | sed -e "s/.*: //"'
#alias cfdomain='cfendpoint | sed -e "s/ec2-\([^.]*\).*/\1/" | tr - . | sed -e "s/$/.xip.io/"'
#alias cfadminpass='juju run --unit uaa/0 "relation-get -r \$(relation-ids credentials) admin-password cloudfoundry/0"'
#alias cflogin='juju expose haproxy && cf api http://api.`cfdomain` && cf auth admin `cfadminpass` && cf create-space -o juju-org my-space && cf target -o juju-org -s my-space'
#function cfdep() {
# jd local:trusty/cloudfoundry && juju set cloudfoundry admin_secret=`juju-secret` placement=dense generate_dependents=true "$@" && watch juju pprint -a
#}
function cfswitch() {
(cd ~/juju/charms/trusty; rm -f cloudfoundry; ln -s ../../cf/$1 cloudfoundry)
}
unalias rqd 2> /dev/null
unset -f rqd
function rqd() {
image='jujusolutions/charmbox'
branch='devel'
net=''
jr=$HOME/juju/envs/rq
while [[ $# > 0 ]]; do
case "$1" in
-l) branch='latest'
net='--net=host'
shift ;;
-d) branch='devel'
net=''
shift ;;
-c) image='seman/cwrbox'
branch='latest'
net=''
shift ;;
-e) jr="$JR"
shift ;;
*) break
esac
done
deployer_cache=/tmp/deployer-store-cache-$$
mkdir $deployer_cache
chmod a+wx $deployer_cache
docker run $net --rm \
--detach-keys 'ctrl-l,d' \
-v ${HOME}/.go-cookies:/home/ubuntu/.go-cookies \
-v ${HOME}/.bashrc:/home/ubuntu/.bashrc \
-v ${HOME}/.bash_aliases:/home/ubuntu/.bash_aliases \
-v ${HOME}/.devhelpers:/home/ubuntu/.devhelpers \
-v ${HOME}/.vimrc:/home/ubuntu/.vimrc \
-v ${HOME}/.vim:/home/ubuntu/.vim \
-v ${HOME}/bin:/home/ubuntu/bin \
-v ${HOME}/lib/liquidprompt:/home/ubuntu/lib/liquidprompt \
-v ${HOME}/.config/liquidpromptrc:/home/ubuntu/.config/liquidpromptrc \
-v ${HOME}/.config/liquid.ps1:/home/ubuntu/.config/liquid.ps1 \
-v ${HOME}/.juju-plugins:/home/ubuntu/.juju-plugins \
-v ${HOME}/.local/share/juju:/home/ubuntu/.local/share/juju \
-v ${JUJU_HOME}:/home/ubuntu/.juju \
-v $deployer_cache:/home/ubuntu/.juju/.deployer-store-cache \
-v $jr/builds:/home/ubuntu/builds \
-v $jr/xenial:/home/ubuntu/xenial \
-v $jr/trusty:/home/ubuntu/trusty \
-v $jr/precise:/home/ubuntu/precise \
-v $jr/bundle:/home/ubuntu/bundle \
-v $jr/layers:/home/ubuntu/layers \
-v $jr/interfaces:/home/ubuntu/interfaces \
-v /var/tmp/cwr-reports:/var/tmp/cwr-reports \
"$@" \
-it $image:$branch
rm -rf $deployer_cache
}
unalias rq 2> /dev/null
unset -f rq
function rq() {
jr=$HOME/juju/envs/rq
deployer_cache=/tmp/deployer-store-cache-$$
mkdir $deployer_cache
chmod a+wx $deployer_cache
#lxc launch ubuntu:16.10 cwrbox
lxc launch cwrbox cwrbox
{
lxc-mount cwrbox ${HOME}/.bashrc /home/ubuntu/.bashrc
lxc-mount cwrbox ${HOME}/.bash_aliases /home/ubuntu/.bash_aliases
lxc-mount cwrbox ${HOME}/.devhelpers /home/ubuntu/.devhelpers
lxc-mount cwrbox ${HOME}/.vimrc /home/ubuntu/.vimrc
lxc-mount cwrbox ${HOME}/.vim /home/ubuntu/.vim
lxc-mount cwrbox ${HOME}/bin /home/ubuntu/bin
lxc-mount cwrbox ${HOME}/lib/liquidprompt /home/ubuntu/lib/liquidprompt
lxc-mount cwrbox ${HOME}/.config/liquidpromptrc /home/ubuntu/.config/liquidpromptrc
lxc-mount cwrbox ${HOME}/.config/liquid.ps1 /home/ubuntu/.config/liquid.ps1
lxc-mount cwrbox ${HOME}/.juju-plugins /home/ubuntu/.juju-plugins
lxc-mount cwrbox ${HOME}/.local/share/juju /home/ubuntu/.local/share/juju
lxc-mount cwrbox ${HOME}/.go-cookies /home/ubuntu/.go-cookies
lxc-mount cwrbox ${JUJU_HOME} /home/ubuntu/.juju
lxc-mount cwrbox $deployer_cache /home/ubuntu/.juju/.deployer-store-cache
lxc-mount cwrbox $jr/builds /home/ubuntu/builds
lxc-mount cwrbox $jr/xenial /home/ubuntu/xenial
lxc-mount cwrbox $jr/trusty /home/ubuntu/trusty
lxc-mount cwrbox $jr/precise /home/ubuntu/precise
lxc-mount cwrbox $jr/bundle /home/ubuntu/bundle
lxc-mount cwrbox $jr/layers /home/ubuntu/layers
lxc-mount cwrbox $jr/interfaces /home/ubuntu/interfaces
lxc-mount cwrbox /var/tmp/cwr-reports /var/tmp/cwr-reports
#lxc exec cwrbox -- mkdir -p /home/ubuntu/.ssh
lxc file push ${HOME}/.ssh/launchpad.pub cwrbox/home/ubuntu/.ssh/authorized_keys
} > /dev/null
until lxc exec cwrbox service sshd status > /dev/null; do
sleep 0.5
done
ip=$(lxc info cwrbox | grep -E 'eth0:\sinet\s' | awk '{print $3}')
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@$ip
lxc delete --force cwrbox
rm -rf $deployer_cache
}
unset -f promulgate
function promulgate() {
charm_id=${1#cs:}
promulgated=${2:-true}
bhttp put -j https://api.jujucharms.com/charmstore/v5/$charm_id/promulgate Promulgated:=$promulgated
}
unset -f lxc-mount
function lxc-mount() {
container=$1
src="$2"
dst="$3"
device_name=$(basename $src | sed -e 's/[^A-Za-z0-9]/_/g')
lxc config set $container raw.idmap 'both 1000 1000'
lxc config device add $container $device_name disk source="$src" path="$dst"
}
unset -f clean-models
function clean-models() {
if [[ -z "$1" ]]; then
>&2 echo "Must provide a pattern"
return 1
fi
for model in `juju models --format=json | jq -r '.models[].name' | grep "$1"`; do
echo -n "Cleaning $model..."
timeout 60s juju destroy-model --destroy-storage -y $model 2> /dev/null
if [[ $? == 124 ]]; then
echo " timed out"
else
echo " done"
fi
done
}
unalias maas-tunnel 2> /dev/null
unset -f maas-tunnel
function maas-tunnel() {
cmd=${1:-start}
shift
sshoot $cmd maas-tunnel "$@"
}
alias wkc='watch -tcn0.5 kubectl'
function itox() {
last_update=0
while true; do
echo -n "[$(date '+%H:%M:%S')] Waiting for activity..."
# vim makes a dumb 4913 file for every write
tm=$(inotifywait -qr . --exclude 4913 --exclude __pycache__ --exclude '.*\.egg-info' -e close_write --format '%T' --timefmt '%s')
if [[ $tm -ge $last_update ]]; then
echo
echo -n "[$(date '+%H:%M:%S')] Waiting for activity to settle..."
sleep 3 # sleep to let file operations end
echo
last_update=$(date +%s)
tox "$@"
fi
done
}