This repository has been archived by the owner on Jan 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
aliasrc
77 lines (62 loc) · 3.55 KB
/
aliasrc
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
#
# Source this file in your ~/.bashrc or ~/.zshrc using:
# echo "source $PWD/aliasrc" >> ~/.bashrc
# echo "source $PWD/aliasrc" >> ~/.zshrc
#
# Utf8 exports
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# Local apps
export PATH=$HOME/bin:$PATH
# Maven
export MAVEN_OPTS="-Xmx4096m -XX:MaxPermSize=500m -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
# Jenv
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
# Pyenv
#export PATH="$HOME/.pyenv/bin:$PATH"
#eval "$(pyenv init -)"
#eval "$(pyenv virtualenv-init -)"
mgmtscp() {
MS=$1
ROOT=$PWD
echo "[acs server] Stopping MS: $MS"
sshpass -pP@ssword123 ssh -o StrictHostKeyChecking=no root@$MS "systemctl stop cloudstack-management"
echo "[acs server] Cleaning old jar on server: $MS"
sshpass -pP@ssword123 ssh -o StrictHostKeyChecking=no root@$MS "rm -f /usr/share/cloudstack-management/lib/cloudstack*jar"
sshpass -pP@ssword123 ssh -o StrictHostKeyChecking=no root@$MS "rm -f /usr/share/cloudstack-management/lib/cloud-client-ui*jar"
sshpass -pP@ssword123 ssh -o StrictHostKeyChecking=no root@$MS "mv /var/log/cloudstack/management/management-server.log /var/log/cloudstack/management/management-server.log-`date +%Y%m%dT%H%M%S`"
echo "[acs server] Copying jar to server: $MS"
sshpass -pP@ssword123 scp -Cv -o StrictHostKeyChecking=no $ROOT/client/target/cloud-client-ui-*.jar root@$MS:/usr/share/cloudstack-management/lib/
echo "[acs server] Copying systemvm.iso"
sshpass -pP@ssword123 scp -Cv -o StrictHostKeyChecking=no $ROOT/systemvm/dist/systemvm.iso root@$MS:/usr/share/cloudstack-common/vms/
echo "[acs server] Starting MS: $MS"
sshpass -pP@ssword123 ssh -o StrictHostKeyChecking=no root@$MS "systemctl start cloudstack-management"
}
agentscp() {
ROOT=$PWD
echo "[acs agent] Syncing changes to agent: $1"
echo "[acs agent] Copied systemvm.iso"
scp $ROOT/systemvm/dist/systemvm.iso root@$1:/usr/share/cloudstack-common/vms/
echo "[acs agent] Syncing python lib changes to agent: $1"
scp -r $ROOT/python/lib/* root@$1:/usr/lib64/python2.6/site-packages/ 2>/dev/null || true
scp -r $ROOT/python/lib/* root@$1:/usr/lib64/python2.7/site-packages/ 2>/dev/null || true
echo "[acs agent] Syncing scripts"
scp -r $ROOT/scripts/* root@$1:/usr/share/cloudstack-common/scripts/
echo "[acs agent] Syncing kvm hypervisor jars"
ssh root@$1 "rm -f /usr/share/cloudstack-agent/lib/*"
scp -r $ROOT/plugins/hypervisors/kvm/target/*jar root@$1:/usr/share/cloudstack-agent/lib/
scp -r $ROOT/plugins/hypervisors/kvm/target/dependencies/*jar root@$1:/usr/share/cloudstack-agent/lib/
echo "[acs agent] Syncing cloudstack-agent config and scripts"
scp $ROOT/agent/target/transformed/log4j-cloud.xml root@$1:/etc/cloudstack/agent/
ssh root@$1 "sed -i 's/INFO/DEBUG/g' /etc/cloudstack/agent/log4j-cloud.xml"
ssh root@$1 "sed -i 's/logs\/agent.log/\/var\/log\/cloudstack\/agent\/agent.log/g' /etc/cloudstack/agent/log4j-cloud.xml"
scp $ROOT/agent/target/transformed/libvirtqemuhook root@$1:/usr/share/cloudstack-agent/lib/
scp $ROOT/agent/target/transformed/cloud-setup-agent root@$1:/usr/bin/cloudstack-setup-agent
ssh root@$1 "sed -i 's/@AGENTSYSCONFDIR@/\/etc\/cloudstack\/agent/g' /usr/bin/cloudstack-setup-agent"
scp $ROOT/agent/target/transformed/cloud-ssh root@$1:/usr/bin/cloudstack-ssh
scp $ROOT/agent/target/transformed/cloudstack-agent-upgrade root@$1:/usr/bin/cloudstack-agent-upgrade
ssh root@$1 "chmod +x /usr/bin/cloudstack*"
ssh root@$1 "systemctl status cloudstack-agent && systemctl restart cloudstack-agent"
echo "[acs agent] Copied all files, start hacking!"
}