Complete Plugin Functional Tests
[multicloud/k8s.git] / vagrant / node.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2018
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 -o nounset
12 set -o pipefail
13 set -o xtrace
14
15 # usage() - Prints the usage of the program
16 function usage {
17     cat <<EOF
18 usage: $0 [-v volumes]
19 Optional Argument:
20     -v List of key pair values for volumes and mount points ( e. g. sda=/var/lib/docker/,sdb=/var/lib/libvirt/ )
21 EOF
22 }
23
24 # mount_external_partition() - Create partition and mount the external volume
25 function mount_external_partition {
26     local dev_name="/dev/$1"
27     local mount_dir=$2
28
29     sfdisk $dev_name --no-reread << EOF
30 ;
31 EOF
32     mkfs -t ext4 ${dev_name}1
33     mkdir -p $mount_dir
34     mount ${dev_name}1 $mount_dir
35     echo "${dev_name}1 $mount_dir           ext4    errors=remount-ro,noatime,barrier=0 0       1" >> /etc/fstab
36 }
37
38 while getopts "h?v:" opt; do
39     case $opt in
40         v)
41             dict_volumes="$OPTARG"
42             ;;
43         h|\?)
44             usage
45             exit
46             ;;
47     esac
48 done
49
50 swapoff -a
51 if [[ -n "${dict_volumes+x}" ]]; then
52     for kv in ${dict_volumes//,/ } ;do
53         mount_external_partition ${kv%=*} ${kv#*=}
54     done
55 fi