delete private key for security
[bottlenecks.git] / utils / infra_setup / vm_dev_setup / common.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 set -x
12
13 generate_ssh_key() {
14     uname -a
15     whoami
16     if [ ! -d ~/.ssh ]; then
17         mkdir ~/.ssh
18     fi
19
20     chmod 600 ~/.ssh/id_rsa
21
22     if [ ! -d /root/.ssh ]; then
23         mkdir /root/.ssh
24     fi
25     
26     sudo sed -ie 's/ssh-rsa/\n&/g' /root/.ssh/authorized_keys
27     sudo sed -ie '/echo/d' /root/.ssh/authorized_keys
28 }
29
30 configue_nameserver()
31 {
32     echo "Bottlenecks: configue nameserver"
33     sudo rm /etc/resolv.conf
34     sudo echo "nameserver 8.8.8.8" >> /etc/resolv.conf
35     sudo echo "nameserver 8.8.4.4" >> /etc/resolv.conf
36
37     ping -c 1 www.google.com
38 }
39
40 install_packages()
41 {
42     echo "Bottlenecks: install preinstall packages in VM"
43     sudo apt-get update
44
45     for i in $@; do
46         if ! apt --installed list 2>/dev/null |grep "\<$i\>"
47         then
48             sudo apt-get install -y --force-yes $i
49         fi
50     done
51 }
52
53 hosts_config()
54 {
55     echo "Bottlnecks: hosts config"
56     sudo echo "
57 $rubbos_benchmark rubbos-benchmark
58 $rubbos_client1 rubbos-client1
59 $rubbos_client2 rubbos-client2
60 $rubbos_client3 rubbos-client3
61 $rubbos_client4 rubbos-client4
62 $rubbos_control rubbos-control
63 $rubbos_httpd rubbos-httpd
64 $rubbos_mysql1 rubbos-mysql1
65 $rubbos_tomcat1 rubbos-tomcat1
66 " >> /etc/hosts
67 }
68
69 set +x
70