summaryrefslogtreecommitdiffstats
path: root/utils/infra_setup/vm_dev_setup/common.sh
blob: 1acd97ead092008b17cf6b68133944a02d16823d (plain)
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
#!/bin/bash
##############################################################################
# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

set -x

generate_ssh_key() {
    uname -a
    whoami
    if [ ! -d ~/.ssh ]; then
        mkdir ~/.ssh
    fi

    cat << EOF > ~/.ssh/id_rsa
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAsJsfP/OlXNcqqqZTD5Jv8OsAdq+WJegozjfOSqOUszxKZ8rC
cDucoGzApUE28wlM7SKRXjvA+sXVpYT5oTBCSFrUYfg8dLMAfgcjK2hkz/dscSqN
rpFs2COnrtuS5iV/mtZZlT5nsEKvunT8yMIAmb8A/FFXuS/ndBD9q294p4kFaAc5
LFJoS9zeo6di4KbHH4tclxYIxXS6Q7AnBXDPkOsEFAtvqhgWGuUcanq3FsyEkm7w
LGMAu1HqZoxaXI91v1l9kHDggyJQM3lEbwvD2zncwrYHjIboR9uPfQXCFEszzKY8
76UYh6+Unhf86z3lvthItTHx4taqwQsUvCQarQIDAQABAoIBAHF4ea+hYFIyfVt/
2kZbFEl69KVNU++vJui4uncCe3xd9ICTqjJqWsxIk86aBDBLfX2vhC9DvU5i5k6f
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sVRc20qG1RqMiCKcqveExqpMqn1
oV2vefV/XJtj43/jrlrGfCoI+RNVImsvp4dwKzr7YOI8Fcqf1e3G
-----END RSA PRIVATE KEY-----
EOF

    cat << EOF > ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCwmx8/86Vc1yqqplMPkm/w6wB2r5Yl6CjON85Ko5SzPEpnysJwO5ygbMClQTbzCUztIpFeO8D6xdWlhPmhMEJIWtRh+Dx0swB+ByMraGTP92xxKo2ukWzYI6eu25LmJX+a1lmVPmewQq+6dPzIwgCZvwD8UVe5L+d0EP2rb3iniQVoBzksUmhL3N6jp2Lgpscfi1yXFgjFdLpDsCcFcM+Q6wQUC2+qGBYa5RxqercWzISSbvAsYwC7UepmjFpcj3W/WX2QcOCDIlAzeURvC8PbOdzCtgeMhuhH2499BcIUSzPMpjzvpRiHr5SeF/zrPeW+2Ei1MfHi1qrBCxS8JBqt bottlenecks@bottlenecks.opnfv.org
EOF
    chmod 600 ~/.ssh/id_rsa

    if [ ! -d /root/.ssh ]; then
        mkdir /root/.ssh
    fi

    sudo cat << EOF > /root/.ssh/id_rsa
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAsJsfP/OlXNcqqqZTD5Jv8OsAdq+WJegozjfOSqOUszxKZ8rC
cDucoGzApUE28wlM7SKRXjvA+sXVpYT5oTBCSFrUYfg8dLMAfgcjK2hkz/dscSqN
rpFs2COnrtuS5iV/mtZZlT5nsEKvunT8yMIAmb8A/FFXuS/ndBD9q294p4kFaAc5
LFJoS9zeo6di4KbHH4tclxYIxXS6Q7AnBXDPkOsEFAtvqhgWGuUcanq3FsyEkm7w
LGMAu1HqZoxaXI91v1l9kHDggyJQM3lEbwvD2zncwrYHjIboR9uPfQXCFEszzKY8
76UYh6+Unhf86z3lvthItTHx4taqwQsUvCQarQIDAQABAoIBAHF4ea+hYFIyfVt/
2kZbFEl69KVNU++vJui4uncCe3xd9ICTqjJqWsxIk86aBDBLf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IMjsNINPdtzHJCca16lsVRc20qG1RqMiCKcqveExqpMqn1
oV2vefV/XJtj43/jrlrGfCoI+RNVImsvp4dwKzr7YOI8Fcqf1e3G
-----END RSA PRIVATE KEY-----
EOF

    sudo cat << EOF > /root/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCwmx8/86Vc1yqqplMPkm/w6wB2r5Yl6CjON85Ko5SzPEpnysJwO5ygbMClQTbzCUztIpFeO8D6xdWlhPmhMEJIWtRh+Dx0swB+ByMraGTP92xxKo2ukWzYI6eu25LmJX+a1lmVPmewQq+6dPzIwgCZvwD8UVe5L+d0EP2rb3iniQVoBzksUmhL3N6jp2Lgpscfi1yXFgjFdLpDsCcFcM+Q6wQUC2+qGBYa5RxqercWzISSbvAsYwC7UepmjFpcj3W/WX2QcOCDIlAzeURvC8PbOdzCtgeMhuhH2499BcIUSzPMpjzvpRiHr5SeF/zrPeW+2Ei1MfHi1qrBCxS8JBqt bottlenecks@bottlenecks.opnfv.org
EOF
    sudo chmod 600 /root/.ssh/id_rsa

    sudo sed -ie 's/ssh-rsa/\n&/g' /root/.ssh/authorized_keys
    sudo sed -ie '/echo/d' /root/.ssh/authorized_keys
}

configue_nameserver()
{
    echo "Bottlenecks: configue nameserver"
    sudo rm /etc/resolv.conf
    sudo echo "nameserver 8.8.8.8" >> /etc/resolv.conf
    sudo echo "nameserver 8.8.4.4" >> /etc/resolv.conf

    ping -c 1 www.google.com
}

install_packages()
{
    echo "Bottlenecks: install preinstall packages in VM"
    sudo apt-get update

    for i in $@; do
        if ! apt --installed list 2>/dev/null |grep "\<$i\>"
        then
            sudo apt-get install -y --force-yes $i
        fi
    done
}

hosts_config()
{
    echo "Bottlnecks: hosts config"
    sudo echo "
$rubbos_benchmark rubbos-benchmark
$rubbos_client1 rubbos-client1
$rubbos_client2 rubbos-client2
$rubbos_client3 rubbos-client3
$rubbos_client4 rubbos-client4
$rubbos_control rubbos-control
$rubbos_httpd rubbos-httpd
$rubbos_mysql1 rubbos-mysql1
$rubbos_tomcat1 rubbos-tomcat1
" >> /etc/hosts
}

set +x